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


0 Comments   [ + ] Show comments

Answers (4)

Posted by: aogilmor 15 years ago
9th Degree Black Belt
just a guess, but you may want to place chr(34) ASCII double quote around your path, and omit the trailing backslash and wildcard...
Posted by: WiseUser 15 years ago
Fourth Degree Brown Belt
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?
Posted by: WiseUser 15 years ago
Fourth Degree Brown Belt
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.
Posted by: gizmo 15 years ago
Senior Yellow Belt
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 :)
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ