Windows – Run as a different user without a password from an elevated prompt in Windows

impersonationrunaswindowswindows 7

There are a several utilities to run as a different user (eg: runas, cpau, psexec) but all of them require the password for the respective user, even if you are already running with elevated privileges.

I'd like to achieve the following:

  1. I already have an elevated prompt (Administrator)
  2. I'd like to execute a command (eg: calc.exe) as john without typing/passing their password to the launcher utility.

For example, in Unix system you could just:

root@server:~# su - john

Best Answer

I use this all the time. It does take entering a credential the first time it's used (and when the password changes) but that's it.

runas /user:yourusernamehere /savecred "Your Executable Here"

If you save this command as part of a bat file you can create a shortcut that will launch this with administrative rights using a target like the following.

C:\Windows\System32\cmd.exe /c "C:\yourbatfilehere.bat"