I am setting permissions on a Home drive and I can't get it to work. It doesn't error on me so I know that is is Close, but I can't figure out why this won't work. During my testing, if I set strBackupFolder to a Const path, it works perfectly. It clears all the default rights and sets the rights to that subfolder to: Full Control for the user and Full Control for the Domain Admin group. No one esle has access to it. But when take aways the Const path and I insert this function into my full script and let strBackupFolder be feed the folder that is created, it doesn't change the permissions. All it does it add the user name with empty properties. It doesn't clear out the existing permissions and it doesn't add the domain admin group. I think that I am close, but I must be missing something small.
Can someone help me out
Set objNetwork = WScript.CreateObject("WScript.Network")
strUsername2 = objNetwork.UserDomain & "\" & objNetwork.UserName
a = executePermissions()
strHomeFolder = strBackupFolder
strUser = strUsername2
Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strHomeFolder) Then
' Assign user permission to home folder.
strCMD = "%COMSPEC% /c Echo Y| cacls " & strHomeFolder & " /t /c /g Allied\G_CSOG:F "& strUser & ":F"
intRunError = objShell.Run(strCMD, 2, True)
If intRunError <> 0 Then
Wscript.Echo "Error assigning permissions for user " & strUser & " to home folder " & strHomeFolder