Sign in to follow this  
Followers 0
wosteen

RunAs and Windows 7

3 posts in this topic

I have a question regarding the use of RunAs under Windows 7.

Until recently, we've been a completely WinXP SP3 shop. I've used the following code (flawlessly) to make a script run itself with elevated privileges:

RunAs($USERNAME,$DOMAIN,$PASSWORD,0,@ComSpec & " /c " & Chr(34) & @ScriptFullPath & Chr(34),@TempDir,@SW_HIDE)
If @error Then MsgBox(4096+32,@Error, "Error starting under admin mode")

Under Windows 7, this process no longer functions, ending with @Error = 1. After much hair-pulling and experimentation, I finally got it to work under 7 by changing the logon_flag from 0 to 4. I'm afraid I don't really understand what this does, only that it worked... mostly.

This seems to work fine on 32-bit Win7. However, if I run it on 64-bit Win7, I get the same results as before... failure with @Error = 1. No matter what I set the flag to, I get the same results. I've tried compiling the script as 32 bit and also 64 bit with no differences.

Any ideas where this might be going wrong?

Thanks in advance!

Wayne

Share this post


Link to post
Share on other sites



/bump back to front page :)

Share this post


Link to post
Share on other sites

Did you ever get this to work? I have run into exactly the same problem.

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  
Followers 0