sheck Posted July 18, 2008 Share Posted July 18, 2008 I was wondering if it's possible to execute a command as a different user inside AutoIt without restarting script ? For example if I start script as a normal user in XP, but want to run some commands inside that script as Admin without running the whole script as Admin. Live and Learn, 'cause Knowledge is Super Power. Link to comment Share on other sites More sharing options...
Paulie Posted July 18, 2008 Share Posted July 18, 2008 RunAs() ? Link to comment Share on other sites More sharing options...
sheck Posted July 18, 2008 Author Share Posted July 18, 2008 RunAs()?According to documentation RunAs() only executes files (EXE, BAT, COM, or PIF). I need to run a command such as FileDelete("").How can I do that ? Live and Learn, 'cause Knowledge is Super Power. Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 18, 2008 Share Posted July 18, 2008 You can't. Link to comment Share on other sites More sharing options...
sheck Posted July 18, 2008 Author Share Posted July 18, 2008 You can't.That's a shame. Oh well, I will have to go around it. Live and Learn, 'cause Knowledge is Super Power. Link to comment Share on other sites More sharing options...
DW1 Posted July 18, 2008 Share Posted July 18, 2008 Isn't that exactly what #RequireAdmin does? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
sheck Posted July 18, 2008 Author Share Posted July 18, 2008 (edited) Isn't that exactly what #RequireAdmin does?No, that just tells Windows that this script can be executed only by someone with Admin Rights. Edited July 18, 2008 by sheckandar Live and Learn, 'cause Knowledge is Super Power. Link to comment Share on other sites More sharing options...
Paulie Posted July 18, 2008 Share Posted July 18, 2008 Well, you could always do it with command prompt i think, i've never tried this $Path = @DesktopDir&"\foo.txt" RunAs($sUserName, @ComputerName, $sPassword, 0, @ComSpec & " /c " & 'del "'&$Path&'"', @SystemDir, @SW_HIDE) Link to comment Share on other sites More sharing options...
sheck Posted July 18, 2008 Author Share Posted July 18, 2008 Well, you could always do it with command prompt i think, i've never tried this $Path = @DesktopDir&"\foo.txt" RunAs($sUserName, @ComputerName, $sPassword, 0, @ComSpec & " /c " & 'del "'&$Path&'"', @SystemDir, @SW_HIDE) Yes you can, however I would like not to do it that way, because not all commands can be read with STDOUR_READ() and I need to know exit code. Live and Learn, 'cause Knowledge is Super Power. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now