Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Windows 10 / How to Run a Program as a Different User (RunAs) in Windows 10?

August 3, 2020 Windows 10

How to Run a Program as a Different User (RunAs) in Windows 10?

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 another user (usually elevated) privileges.

For example, you can use the RunAs to install apps or run MMC snap-ins under the administrator account in an unprivileged user session. The opportunity to run a program as a different user may be useful when an application is configured under another user (and stores its settings in another user’s profile, which the current user cannot access), but it must be started with the same settings in another user’s session.

[/alert]

In Windows 10 there are several ways to run a program/process on behalf of another user.

Contents:
  • How to Run an App as Different User from File Explorer?
  • “Run As Different User” Option is Missing in Windows 10
  • Using the RunAs Command to Run a Program as Another User from CMD
  • How to Use RunAs Without Password Prompt?
  • How to Create a Shortcut to Run As Different User?
  • How to Run MMC Snap-Ins As a Different User?
  • Add “Run As” Option to Start Menu in Windows 10

The Secondary Log-on service (seclogon) is responsible for the ability to run programs as different user in Windows. If this service is stopped, all of the described RunAs methods won’t work. You can check that the service is started with the following PowerShell command:

Get-Service seclogon

secondary logon service needs to use runas feature on windows

How to Run an App as Different User from File Explorer?

The easiest way to run an application on behalf of another user is to use the Windows File Explorer GUI. Just find an application (or a shortcut) you want to start, press the Shift key and right-click on it. Select Run as different user in the context menu.

[alert]Note. If the menu item “Run as different user” is missing, see the next section.

Run as different user option

In the next window, specify the name and password of the user under whose account you want to run the application and click OK.

Note. If you need to specify a domain user, one of the following formats of the name is used: UserName@DomainName or DomainName\UserName.

windiows security dialog - enter different user's password

Important. Running the program on behalf of different user is possible if the account has a password. Using RunAs for a user with an empty password won’t work.

Open the Task Manager and make sure that the application is running under the specified user account.

taskmanager the application is running under different user

“Run As Different User” Option is Missing in Windows 10

If there is no Run as different user option in the File Explorer context menu, open the Local Group Policy Editor (gpedit.msc) and make sure that the Require trusted path for credential entry policy is disabled (or not configured) in Computer Configuration -> Administrative Templates -> Windows Components -> Credential User Interface.

GPO: Require trusted path for credential entry

Using the RunAs Command to Run a Program as Another User from CMD

You can use the Windows built-in cli tool runas.exe to run apps applications as a different user from the command prompt. The runas command also lets you to save the user’s password to the Windows Credential Manager so that you don’t have to enter it every time.

Open the command prompt (or the Run window by pressing Win+R). To start the Notepad.exe under the administrator account, run this command:

runas /user:admin "C:\Windows\notepad.exe"

Tip. If the username contains spaces, put quotes around it:

runas /user:"antony jr" notepad.exe

using runas in command prompt

In the next window, the prompt “Enter the password for admin” appears, where you have to enter the user’s password and press Enter.

Enter the password for admin

Your application should open. In my case, this is cmd.exe. The window title says “running as PCName\username“:

cmd running as different user in windows 10

For example, you can open the Control Panel under a different user:

runas /user:admin control

If you need to run a program under a domain user, use the following name format: UserName@DomainName or DomainName\UserName. For example, to open a text file using notepad on behalf of a domain user, use the command:

runas /user:corp\server_admin "C:\Windows\system32\notepad.exe C:\ps\region.txt"

Attempting to start an app as different user

Enter the password for corp\server_admin:
Attempting to start C:\Windows\system32\notepad.exe C:\ps\region.txt as user "corp\server_admin " ...

Sometimes you need to run a program as a domain user from a computer that is not joined to the AD domain. In this case, you need to use the following command (It is assumed that the DNS server specified in your computer’s network settings can resolve this domain name):

runas /netonly /user:contoso\bmorgan cmd.exe

If you don’t want to load user profile when starting the program as different user, use the /noprofile parameter. This allows the application to launch much faster, but may cause incorrect operation of programs that store app data in the user’s profile.

How to Use RunAs Without Password Prompt?

You can save the user credentials (with password) that you enter. The /savecred parameter is used for this.

runas /user:admin /savecred “C:\Windows\cmd.exe”

After specifying the password, it will be saved to the Windows Credential Manager.

The next time you run the runas command under the same user with the /savecred key, Windows will automatically use the saved password from the Credential Manager 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

windows runas with savecred option

However, using the /savecred parameter is not safe. Because 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 Windows from saving passwords (and never save the password of the privileged administrator accounts).

Note. In addition, /savecred doesn’t work in Windows Home edition.

How to Create a Shortcut to Run As Different User?

You can create a shortcut on your desktop that allows you to run the program as a different user. Just create a new shortcut, and specify the runas command with the necessary parameters in the Location field

shortcut with runas command

When you run such a shortcut, you will be prompted to enter a user password.

If you additionally specify the /savecred parameter in the runas shortcut, then the password will be prompted only once. The password will be saved in Credential Manager and automatically used when you running the shortcut without prompting for a password.

Such shortcuts are quite often used to run programs that require elevated permissions to run. However, there are safer ways to run a program without administrator privileges, or disable the UAC prompt for a specific application.

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 the Active Directory Users and Computers (ADUC) RSAT snap-in as a different user:

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).

Add “Run As” Option to Start Menu in Windows 10

By default in Windows 10 Start Menu items 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).

Show “Run as different user” command on Start

Or, if the gpedit.msc is missing, create a new DWORD parameter with the name ShowRunasDifferentuserinStart and value 1 in the registry key HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer. You can use the following PowerShell command to add the reg parameter:

New-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\CurrentVersion\Explorer" -Name ShowRunasDifferentuserinStart -Value 1 -PropertyType DWORD -Force

ShowRunasDifferentuserinStart registry

Update the Group Policy settings (gpupdate /force) and make sure that a new context menu More -> Run as different user has appeared for the programs in the Start menu.

Run as different user in start menu

9 comments
8
Facebook Twitter Google + Pinterest
previous post
Configuring Network Adapter Settings with PowerShell: IP Address, DNS, Default Gateway, Static Routes
next post
Ubuntu/Mint/Kali Boots to Initramfs Prompt in BusyBox

Related Reading

Windows Security Won’t Open or Shows a Blank...

May 17, 2022

How to Manually Install Windows Updates from CAB...

May 16, 2022

RDS and RemoteApp Performance Issues on Windows Server...

May 16, 2022

Fix: You’ll Need a New App to Open...

April 27, 2022

How to Completely Uninstall Previous Versions of Office...

April 26, 2022

9 comments

Tariq March 26, 2020 - 7:11 pm

Great write up. It worked like a charm.

Reply
Mo May 19, 2020 - 9:04 am

perfect! thank you!

Reply
Akram Naeem August 20, 2020 - 6:29 am

This is perfect article

Reply
saif October 27, 2020 - 3:49 pm

i use run command for different user and it ask me for writing password on new cmd window but i am unable to write . i have checked runas.exe properties in which administrator have only read and execute persmission .kindly suggest me solution

Reply
kid119 March 9, 2021 - 2:08 pm

Great write up. Everything is working as described. When I use runas the application is launching in the specified users background how do I launch to the foreground so the application opens on top for the user?

Reply
MATT@OSCO March 9, 2021 - 3:35 pm

The last option was perfect thanks, I can see why that might be disabled by default but I wish it wasn’t!

Reply
Pavel March 25, 2021 - 2:07 pm

works well, would it be possible to specify the password within this shortcut so there is no need to type it all the time?

Reply
Thorsten Schöning April 28, 2021 - 4:03 pm

Beware, while “runas” creates a new user context, especially in case of admins the created processes ARE NOT elevated the same kind like when “Run as Administrator” is used.

> Do Not Use Runas to Launch an Elevated Process

> Be aware that runas does not provide the ability to launch an application with an elevated access token, regardless of whether it is a
> standard user with privileges like a Backup Operator or an administrator. The runas command grants the user the ability to launch
> an application with different credentials. The best method to use to launch an application with a different account is to perform the
> action programmatically by using a service and not rely on the user to run the component as a different user. If your program
> programmatically uses the runas command, ensure that it is not intended to launch an elevated process.

https://msdn.microsoft.com/en-us/library/bb756922.aspx

That limitation can be worked around by using additional tools like “ShelExec” the verb “runas”, which seems to behave differently and elevate a process as well.

> ShelExec /Verb:runas cmd.exe

Reply
Karthick January 25, 2022 - 1:46 pm

A very useful article, thanks!

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows 7
  • Windows Server 2019
  • Windows Server 2016
  • Windows Server 2012 R2
  • PowerShell
  • VMWare
  • Hyper-V
  • MS Office

Recent Posts

  • Create Organizational Units (OU) Structure in Active Directory with PowerShell

    May 17, 2022
  • Windows Security Won’t Open or Shows a Blank Screen on Windows 10/ 11

    May 17, 2022
  • How to Manually Install Windows Updates from CAB and MSU Files?

    May 16, 2022
  • RDS and RemoteApp Performance Issues on Windows Server 2019/2016

    May 16, 2022
  • Deploying Software (MSI Packages) Using Group Policy

    May 12, 2022
  • Updating VMware ESXi Host from the Command Line

    May 11, 2022
  • Enable or Disable MFA for Users in Azure/Microsoft 365

    April 27, 2022
  • Fix: You’ll Need a New App to Open This Windows Defender Link

    April 27, 2022
  • How to Reset an Active Directory User Password with PowerShell and ADUC?

    April 27, 2022
  • How to Completely Uninstall Previous Versions of Office with Removal Scripts?

    April 26, 2022

Follow us

woshub.com

ad

  • Facebook
  • Twitter
  • RSS
Popular Posts
  • How to Allow Multiple RDP Sessions in Windows 10 and 11?
  • How to Repair EFI/GPT Bootloader on Windows 10?
  • How to Restore Deleted EFI System Partition in Windows 10?
  • How to Run Program without Admin Privileges and to Bypass UAC Prompt?
  • Error Code: 0x80070035 “The Network Path was not found” after Windows 10 Update
  • How to Download APPX File from Microsoft Store for Offline Installation?
  • How to Disable UAC Prompt for Specific Applications in Windows 10?
Footer Logo

@2014 - 2018 - Windows OS Hub. All about operating systems for sysadmins


Back To Top