Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Run icacls as administrator

$
0
0
I'm trying to create a script to run the icacls function to change some folder permissions within a script where the user of the script does not have admin rights. I'm using the RunAsWait function like so:

#RequireAdmin
;~some other code
Local $pid = RunAsWait($AdminUser,@ComputerName,$pw,0,@ComSpec & " /c icacls " & $configDIR & " /grant " & $newUser &":F",@SystemDir,@SW_HIDE)

Nothing happens and the line exits 5.

But if I go through the hassle of navigating to c:\windows\system32 and right clicking cmd.exe > run as administrator > enter password, then at command line prompt type and execute: icacals [the directory] /grant [the user]:F
everything works fine.

It appear to this noob that the hassle of navigating>right clicking etc cmd.exe is behaves differently than RunAsWait with proper credentials.

Can anyone help! I've spent a lot of time on this and don't know what else to do...
Thanks

(Oh, script will always be running on Windows 7 starter 32)

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>