Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible to continue runas /u:domain\admin cmd with followup commands in the new CMD window? I tried this: (didn't work) Runas different user to launch CMD and run command

What I want is to run msra /offerra using CMD however I need to first run CMD as another user with admin privs using runas as shown above.

share|improve this question
    
My commands had a syntax error. I fixed it. –  Dennis Mar 4 '13 at 16:01

1 Answer 1

Those instructions were wrong and have been fixed. Here's the usage for runas:

RUNAS USAGE:

RUNAS [ [/noprofile | /profile] [/env] [/savecred | /netonly] ]
        /user:<UserName> program

RUNAS [ [/noprofile | /profile] [/env] [/savecred] ]
        /smartcard [/user:<UserName>] program

RUNAS /trustlevel:<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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.