Jump to content
Sign in to follow this  
boyemillar

Set Folder Permissions

Recommended Posts

boyemillar

Anybody got any ideas on how to set permissions on a folder with AutoIT, i usually use the following command in batch files

CACLS c:\program files\{whatever} /E /T /C /G "Domain Users":F

Share this post


Link to post
Share on other sites
weaponx

RunWait('CACLS c:\program files\{whatever} /E /T /C /G "Domain Users":F')

- or -

RunWait(@ComSpec & ' /c CACLS c:\program files\{whatever} /E /T /C /G "Domain Users":F')

Edited by weaponx

Share this post


Link to post
Share on other sites
boyemillar

RunWait('CACLS c:\program files\{whatever} /E /T /C /G "Domain Users":F')

- or -

RunWait(@ComSpec & ' /c CACLS c:\program files\{whatever} /E /T /C /G "Domain Users":F')

Tried both the above and it runs the CACLS command and the dos box runs very quickly and closes and looks like it is having a problem with the switch but most probably the "Domain Users":F part that is causing the problem and it doesnt set the permissions...

Share this post


Link to post
Share on other sites
weaponx

You probably need double quotes around file path with spaces:

$result = RunWait('CACLS "c:\program files\{whatever}" /E /T /C /G "Domain Users":F')

MsgBox(0,"",$result)

- or -

$result = RunWait(@ComSpec & ' /c CACLS "c:\program files\{whatever}" /E /T /C /G "Domain Users":F')

MsgBox(0,"",$result)

Most command line programs return 1 for SUCCESS whereas Autoit functions return 0 for SUCCESS.

Share this post


Link to post
Share on other sites
boyemillar

You probably need double quotes around file path with spaces:

$result = RunWait('CACLS "c:\program files\{whatever}" /E /T /C /G "Domain Users":F')

MsgBox(0,"",$result)

- or -

$result = RunWait(@ComSpec & ' /c CACLS "c:\program files\{whatever}" /E /T /C /G "Domain Users":F')

MsgBox(0,"",$result)

Most command line programs return 1 for SUCCESS whereas Autoit functions return 0 for SUCCESS.

Cheerz

But, The above returns a result of 160

Share this post


Link to post
Share on other sites
boyemillar

Sorry my bad

I had left an extra "\" at the end of the path

Share this post


Link to post
Share on other sites
weaponx

Mine returns 1332. And when I run the same code from the command line it says:

"No mapping between account names and security IDs was done."

Share this post


Link to post
Share on other sites
boyemillar

Cheerz mines is running fine noo with the...

RunWait(@ComSpec & ' /c CACLS "c:\program files\{whatever}" /E /T /C /G "Domain Users":F')

Any ideas on a way to hide the resultant dos window.

Share this post


Link to post
Share on other sites
Jos

RunWait(@ComSpec & ' /c CACLS "c:\program files\{whatever}" /E /T /C /G "Domain Users":F','',@sw_hide)

Is nicely explained in the Helpfile ... :D


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
weaponx

RunWait(@ComSpec & ' /c CACLS "c:\program files\{whatever}" /E /T /C /G "Domain Users":F', @ScriptDir, @SW_HIDE)

Check out RunWait() in the help file.

EDIT: Milliseconds late.

Edited by weaponx

Share this post


Link to post
Share on other sites
boyemillar

Cheerz very much for the help peeps

I will need to start reading the help files

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×