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)
#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)