Jump to content

Recommended Posts

Posted

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.
Posted

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.
Posted

You can't.

That's a shame. Oh well, I will have to go around it.

Live and Learn, 'cause Knowledge is Super Power.
Posted (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 by sheckandar
Live and Learn, 'cause Knowledge is Super Power.
Posted

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...