So, I am doing an installation project, all written in VB.NET, and I need to give the NetworkService account permission to a specific folder.
The following code works fine (Windows 7 - ru-US):
Dim dInfo As New DirectoryInfo("C:\FolderOrFileToGivePermission") Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl() dSecurity.AddAccessRule(New FileSystemAccessRule("NETWORK SERVICE", FileSystemRights.FullControl, AccessControlType.Allow)) dInfo.SetAccessControl(dSecurity)
The problem started when I try to use the same code on my Windows 7, Vista or XP ( all in PT-BR ), I found that there is no "NETWORK SERVICE", the correct name is "Serviço de Rede".
I need this name to entitle the correct user.
After much research on all three operating systems, I found that the identifier for the user is "S-1-5-20", his path in the registry is Computer \ HKEY_USERS \ S-1-5-20, and the default folder for him is: C: \ Windows \ ServiceProfiles \ NetworkService
But I still haven't found the actual “localizable” name, and I need it to be dynamic, because this system will be installed in many different countries (different machines and cultures).
Thanks in advance.
source share