In all supported Windows versions it is possible to run applications on behalf of another user (Run As) in the current session. This allows you to run a script (.bat, .cmd, .vbs, .ps1), an executable (.exe) or an application installation (.msi, .cab) with the privileges of another user (elevated).
For example, due to using Run As, you can run the installation of a program or open the MMC snap-in under the administrator account in an unprivileged user session. The opportunity to run a program as a different user may be useful in the situations when an application is configured under another user (and stores its settings in another person’s profile, which the current user cannot access), but it must be started with the same settings in another user’s session.
In Windows 10 there are several ways to start a process on behalf of another user.
How to Run a Program on Behalf of Another User from File Explorer
The easiest way to start an application on behalf of another user is to use the File Explorer GUI. Just find an application (or a shortcut) you want to start, press Shift and right-click it. Select Run as different user in the context menu.
In the next window, specify the name and password of the user under whose account you want to run the application and click OK.
Open the Task Manager and make sure that the application is running under the specified user.
“Run As Different User” Option is Missing
If there is no Run as different user option in the context menu, open Local Group Policy Editor (gpedit.msc) and make sure that Require trusted path for credential entry policy is disabled (or not configured) in Computer Configuration -> Administrative Templates -> Windows Components -> Credential User Interface.
Using Runas in CMD to Run a Program under a Different User Account
You can run a program or a script as a different user from the command prompt or an application shortcut. Also, this method assumes the possibility of saving a user’s password not to enter it each time. To do it, you can use a console utility runas.exe.
Open the command prompt (or the Run window by pressing Win+R). To start the Notepad under the admin account, run this command:
runas /user:admin "C:\Windows\notepad.exe"
In the next window, the prompt “Enter the password for admin” appears, where you have to enter the user’s password and press Enter.
If you needto run a program under a domain user, use the following name format: UserName@DomainName or DomainName\UserName. For example, to use a notepad to open a text file on behalf of a domain user, use the command:
runas /user:corp\domain_admin "C:\Windows\system32\notepad.exe C:\ps\region.txt"
Enter the password for corp\domain_admin:
Attempting to start C:\Windows\system32\notepad.exe C:\ps\region.txt as user "corp\domain_admin " ...
To create a desktop shortcut to run a program as another user, just create a new shortcut, and specify the runas command in the location field.
When you start this shortcut, you will be prompted to enter a user password.
To save the password of a different user, use /savecred key.
runas /user:admin /savecred "C:\Windows\notepad.exe"
After you have specified the password, it is saved in Windows Credential Manager, and if the runas command is run as the same user with the /savecred key, the system will automatically use the saved password without prompting to enter it again.
To display a list of saved credentials in Credential Manager, use the following command:
rundll32.exe keymgr.dll, KRShowKeyMgr
However, using the /savecred parameter is not safe, since a user, in which profile it is saved, can use it to run any command with these privileges and even change another user password. Also, it is easy to steal passwords saved in the Credential Manager so it is recommended to prevent a system from storing passwords (and never save the password of the privileged administrator account).
How to Run MMC Snap-Ins As a Different User
In some cases, you have to run one of Windows management snap-ins as a different user. For example, you can use the following command to run Active Directory Users and Computers (ADUC) snap-in:
runas.exe /user:DOMAIN\USER "cmd /c start \"\" mmc %SystemRoot%\system32\dsa.msc"
In the same way you can run any other snap-in (if you know its name).
How to Add “Run As” Option to the Programs in the Start Menu
By default in Windows 10 Start menu (Start screen) elements do not have the “Run As” option. To add the context menu “Run as different user”, enable the Show “Run as different user” command on Start policy in User Configuration -> Administrative Templates ->Start Menu and Taskbar section of the Local Group Policy Editor (gpedit.msc).
Or, if the gpedit.msc is missing, create in the registry key HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer a new DWORD parameter with the name ShowRunasDifferentuserinStart and the value 1.
Update the policies (gpupdate /force) and make sure that a new context menu More -> Run as different user has appeared for the programs in the Start menu.