Jump to content
Sign in to follow this  
KoenG

RunAs problems

Recommended Posts

KoenG

Hi,

I need to RunAs a program with admin-rights, do a little manipulation and then exit the program.

Can someone explain to me why the first example works, and the second does not? I have to use logon flag 0 or 1, I have learned from experience.

All input welcome,

Koen

; This works

Run("notepad.exe")

WinWaitActive("Untitled - Notepad","", 1)

Send("This is a test")

Sleep(1000)

WinClose("Untitled - Notepad")

WinWaitActive("Notepad","", 1)

Send("!N")

;This doesn't work

RunAs("Admin_Account", "Domain_name", "Admin_Pass",0,"notepad.exe")

WinWaitActive("Untitled - Notepad","", 1)

Send("This is a test")

Sleep(1000)

WinClose("Untitled - Notepad")

WinWaitActive("Notepad","", 1)

Send("!N")

Exit

Share this post


Link to post
Share on other sites
Juvigy

Try this out :

RunAs($user, $domain, $pass,0,@ScriptName,@ScriptDir)

Run("notepad.exe")

WinWaitActive("Untitled - Notepad","", 1)

Send("This is a test")

Sleep(1000)

WinClose("Untitled - Notepad")

WinWaitActive("Notepad","", 1)

Send("!N")

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.