Is it possible to continue runas /u:domain\admin
command with followup commands in a new CMD.EXE window?
I tried this but it didn't work: Runas different user to launch CMD and run command
What I want is to run msra /offerra
using CMD.EXE, however I need to first run CMD as another user with admin privileges using runas
as shown above.
Answer
Those instructions were wrong and have been fixed. Here's the usage for runas
:
RUNAS USAGE:
RUNAS [ [/noprofile | /profile] [/env] [/savecred | /netonly] ]
/user: program
RUNAS [ [/noprofile | /profile] [/env] [/savecred] ]
/smartcard [/user:] program
RUNAS /trustlevel: program
Notice that in all three variations, you can specify only a program to be run, nothing else. They mean it: You cannot specify any arguments to the program as separate words. Any arguments must be embedded into the "program" string with surrounding quotes.
Also not made clear is that runas
will not pass the current directories; it always starts in C:\Windows\System32
. So any program you specify must either be in a PATH
directory or given as a full path. You cannot use a relative path. And of course, any ACLs on that executable or the directories on its path must allow access by the user you'd like to run it as.
The good news is that runas
will accept a .cmd
file as a "program".
As a practical matter, what this means is that to do what you want, you'll probably want to create a .cmd
file in a directory both users can access, then pass the full path. For example:
runas /u:Fred "C:\Users\Public\foo.cmd"
The final wrinkle is that runas
can start a program as another user, but it can't elevate. There's no way to cause it to generate the UAC prompt. If you'd like to run something "as administrator" using runas
, you'll have to enable the builtin Administrator account, which always runs elevated anyway, and specify that user name.
If that's not going to work for you and you need a generalized ability to pass arguments and/or current directories or if you need to run something elevated as something other than Administrator, you'll need a genuine su
, like this one.
No comments:
Post a Comment