xcacls and Wscript
I am trying to set permissions using VBScript and xcacls.exe on a folder in Program Files. For whatever reason it will not work. Does anyone have an idea what I am doing wrong?
Set objShell = CreateObject("Wscript.Shell")
objShell.Run("xcacls.exe C:\Program Files\SMfitACT-Calibration-R3.1\* /T /G Everyone:F"),1,True
Thanks,
Phil
Set objShell = CreateObject("Wscript.Shell")
objShell.Run("xcacls.exe C:\Program Files\SMfitACT-Calibration-R3.1\* /T /G Everyone:F"),1,True
Thanks,
Phil
0 Comments
[ + ] Show comments
Answers (4)
Please log in to answer
Posted by:
aogilmor
19 years ago
Posted by:
WiseUser
19 years ago
Aogilmor is right, but your brackets are also in the wrong place (in fact your don't need them at all unless you want the return code).
It should look something like this (although I haven't tested it):
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "xcacls.exe " & Chr(34) & "C:\Program Files\SMfitACT-Calibration-R3.1\*" & Chr(34) & " /T /G Everyone:F", 1, True
Otherwise, you could use the "shortpath" (8.3 format).
By the way, why are you using "xcacls.exe" to do something that the standard windows command "cacls.exe" could do?
It should look something like this (although I haven't tested it):
objShell.Run "xcacls.exe " & Chr(34) & "C:\Program Files\SMfitACT-Calibration-R3.1\*" & Chr(34) & " /T /G Everyone:F", 1, True
Otherwise, you could use the "shortpath" (8.3 format).
By the way, why are you using "xcacls.exe" to do something that the standard windows command "cacls.exe" could do?
Posted by:
WiseUser
19 years ago
Here's the "Cacls.exe" version:
Set objShell = CreateObject("Wscript.Shell")
iRetVal = objShell.Run("%SystemRoot%\System32\Cacls.exe " & Chr(34) & "C:\Program Files\SMfitACT-Calibration-R3.1" & _
Chr(34) & " /E /T /G Everyone:C", 0, True)
Set objShell = Nothing
Msgbox iRetVal
I've added "/E" to edit the ACL instead of overwriting it. I also changed the permissions to "C" because it's usually enough - best practice is to give the most restrictive permissions that are required.
I changed the "WindowStyle" value to 0 in order to make the horrible black box invisible.
I included the full path to "cacls.exe" to ensure that the correct copy is used, and in case the machine "path" environment variable has been corrupted.
I've captured the return value too so we can be sure that the command ran.
iRetVal = objShell.Run("%SystemRoot%\System32\Cacls.exe " & Chr(34) & "C:\Program Files\SMfitACT-Calibration-R3.1" & _
Chr(34) & " /E /T /G Everyone:C", 0, True)
Set objShell = Nothing
Msgbox iRetVal
I've added "/E" to edit the ACL instead of overwriting it. I also changed the permissions to "C" because it's usually enough - best practice is to give the most restrictive permissions that are required.
I changed the "WindowStyle" value to 0 in order to make the horrible black box invisible.
I included the full path to "cacls.exe" to ensure that the correct copy is used, and in case the machine "path" environment variable has been corrupted.
I've captured the return value too so we can be sure that the command ran.
Posted by:
gizmo
19 years ago
hi ....
.... i used "Execute Program From Destination" to run Xcacls ... and it works fine :) .... no need to make a "script" :)
Tab "Execute Immediate" -> "Execute Program From Destination"
.... commandline : cmd /c xcacls ....................
(i included xcacls in the package - so i knew the location, and that the file would be there)
... it took me a while to find out how the commnadline should be .... :)
Gizmo - Denmark :)
.... i used "Execute Program From Destination" to run Xcacls ... and it works fine :) .... no need to make a "script" :)
Tab "Execute Immediate" -> "Execute Program From Destination"
.... commandline : cmd /c xcacls ....................
(i included xcacls in the package - so i knew the location, and that the file would be there)
... it took me a while to find out how the commnadline should be .... :)
Gizmo - Denmark :)
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.