marcelom.github.io

Run `cmd.exe` as another user

Posted on 22 Apr 2013 by Marcelo Moreira — Permalink

Sometimes you need to run command line commands as another user.

I just ran into this the other day, and even thought it is a windows trick, I thought it was worth documenting.

I used it to migrate our AD objects from one domain into another. I used dsget and dsquery extensively for that and needed to issue them several times, and I did not want to type the username and password several times for it.

To accomplish this, just type from another cmd.exe window:

runas /user:u2 "cmd.exe"
Fork me on GitHub