Hi all.
I customized a script that's been floating around on the web for some time to set permissions on a shared folder. the script appears to run and set the permissions properly, however the "IF" statement to display the error keeps displaying everytime it's run. Basically, I want to strip off all of the users permissions except for SYSTEM and CREATOR OWNER and add the User itself.
Code:
Option Explicit
Dim HomeDirectory, intRunError, objShell, objFSO, LogonName
LogonName = "User"
HomeDirectory = "\\SERVERNAME\users\" & LogonName
Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(HomeDirectory) Then
' Assign user permission to home folder.
intRunError = objShell.Run("%COMSPEC% /c Echo Y| cacls "_
& HomeDirectory & " /T /C /G "_
& LogonName & ":F /E /R Administrators ITAdmins", 2, True)
If intRunError <> 0 Then
Wscript.Echo "Error assigning permissions for user " _
& LogonName & " to home folder " & HomeDirectory
Else
Wscript.Echo "Permissions assigned successfully for " _
& LogonName & " to home folder " & HomeDirectory
End If
End If
WScript.Quit
The lines :
Code:
If intRunError <> 0 Then
Wscript.Echo "Error assigning permissions for user " _
& LogonName & " to home folder " & HomeDirectory
is what isn't making sense. I tried adding a line to echo Err.Number and Err.Description and I get an error number of 0 and no description. By the way, LogonName and HomeDirectory are defined the way they are for testing puproses only. This will be added to an existing script which already defines them.
Please help.