Jump to content

RunAs and Windows 7


Recommended Posts

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

Link to comment
Share on other sites

  • 4 months later...

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
 Share

  • Recently Browsing   0 members

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