|

How To Use The Runas Command In Windows (2027)

Runas starts a program under a different user account without signing out of Windows.

The basic form is runas /user:<computer>\<account> <program>, and Windows asks for that account’s password in the window.

Microsoft’s runas page is an archived reference last updated in 2016, so this guide uses only what that page documents.

Table of Contents

Runas quick answers

I want toType this
Open a Command Prompt as another local accountrunas /user:<computer>\<account> cmd
Run a program as a domain accountrunas /user:<domain>\<account> "<program>"
Open a console as a domain administratorrunas /user:contoso\domainadmin "mmc %windir%\system32\compmgmt.msc"
Use an account only for remote network accessrunas /netonly /user:<domain>\<account> "<command>"
Skip loading the account profilerunas /noprofile /user:<account> <program>
See the built-in helprunas /?

Replace the placeholders with your own computer, domain and account names.

What runas does

Microsoft describes runas as a tool that lets a user run specific tools and programs with different permissions than the current logon provides.

It is not limited to administrator accounts, although that is the most common use.

Any user with more than one account can use it to run a program, MMC console or Control Panel item with the other account’s credentials.

Why use runas instead of signing in as an administrator

Microsoft says it is good practice to use an account with restrictive permissions for routine tasks and a broader account only for specific administrative ones.

Runas lets you do that without logging off and back on.

For the simpler case of running a window as administrator on your own account, see how to open Terminal as administrator.

The runas syntax

Microsoft gives the syntax as runas [{/profile | /noprofile}] [/env] [{/netonly | /savecred}] [/smartcard] [/showtrustlevels] [/trustlevel] /user:<UserAccountName> "<ProgramName> <PathToProgramFile>".

The only required parts are /user: with the account name and the program to run.

The account name can be written as <User>@<Domain> or <Domain>\<UserAccountName>.

Runas switches at a glance

SwitchWhat it does
/profileLoads the user profile, which is the default, and cannot be combined with /netonly.
/noprofileDoes not load the profile, so the program may start faster, but some applications can malfunction.
/envUses the current network environment instead of the account local environment.
/netonlySays the credentials are for remote access only, and cannot be combined with /profile.
/savecredUses credentials previously saved by this user, and cannot be combined with /smartcard.
/smartcardTakes the credentials from a smart card, and cannot be combined with /savecred.
/showtrustlevelsDisplays the trust levels you can pass to /trustlevel.
/trustlevelSets the level of authorization the program runs at.
/?Shows help at the command prompt.

Open a Command Prompt

  1. Press the Windows key and type cmd.
  2. Press Enter to open Command Prompt.
  3. Type your runas command and press Enter.
  4. Enter the password only when Windows prompts for it.

Microsoft’s remarks say to type the password only when prompted, so do not put it in the command.

Run a program as a local administrator

To use the Administrator account on your own computer, Microsoft gives two forms for the user switch.

  • /user:<AdministratorAccountName>@<ComputerName>
  • /user:<ComputerName>\<AdministratorAccountName>

Microsoft’s example for an administrative Command Prompt is runas /user:<localmachinename>\administrator cmd.

Run a program as a domain administrator

For a domain account, the user switch takes /user:<AdministratorAccountName>@<DomainName> or /user:<DomainName>\<AdministratorAccountName>.

Microsoft’s example opens Computer Management with runas /user:contoso\domainadmin "mmc %windir%\system32\compmgmt.msc".

Its Notepad example is runas /user:[email protected] "notepad my_file.txt".

Microsoft examples in one place

TaskCommand
Administrative Command Prompt on the local computerrunas /user:<localmachinename>\administrator cmd
Computer Management as a domain administratorrunas /user:contoso\domainadmin "mmc %windir%\system32\compmgmt.msc"
Notepad with a file as another accountrunas /user:[email protected] "notepad my_file.txt"
Tool that administers a server in another forestrunas /netonly /user:<Domain>\<User_Name> "<Command>"

Runas and the Run as administrator menu

Microsoft’s page says the Run as command in the user interface was renamed Run as administrator starting with Windows Vista.

It adds that you should rarely need the command line, because Windows prompts for an administrator password automatically when a task needs one.

The command line is still the way to use a different account entirely, such as a separate local or domain account.

Microsoft also notes that runas can start items as an administrator while you are logged on as a member of another group, such as Users or Power Users.

SituationBetter choice
Your own account is an administrator and you need an elevated windowRun as administrator from the Start menu
You need a different local accountrunas /user:<computer>\<account> <program>
You need a domain account on a domain PCrunas /user:<domain>\<account> <program>
You only need remote access with other credentialsrunas /netonly /user:<domain>\<account> <command>

Use netonly for a server in another domain

Microsoft says runas lets you administer a server in another domain or forest.

The /netonly example uses runas /netonly /user:<Domain>\<User_Name> "<Command>", and that user needs enough permission to administer the server.

What you can run with runas

  • Programs (.exe files).
  • Saved MMC consoles (.msc files).
  • Shortcuts to programs and saved MMC consoles.
  • Control Panel items.

The account must be able to log on to the computer, and the item must be available on the system and to that account.

Things runas cannot do

  • Items such as the Printers folder and desktop items open indirectly and cannot be started with runas.
  • Starting something from a network location can fail, because the credentials used to reach the share differ from those that start the program.
  • Group Policy is not processed for the account whose credentials you supply, which Microsoft says is by design.

If runas fails

Microsoft says the Secondary Logon service might not be running, or the user account might not be valid.

  1. Open Computer Management.
  2. Expand Services and Applications and select Services.
  3. Look for Secondary Logon and check its status.
  4. Test the account by trying to log on with it.

Microsoft’s Run As troubleshooting article for older Windows Server versions says some programs do not support runas, and that it does not work correctly under the LocalSystem account.

Common runas mistakes

  • Writing the account without a computer or domain name.
  • Forgetting the quotes around a program that has arguments.
  • Combining /profile with /netonly, which Microsoft says cannot be used together.
  • Combining /savecred with /smartcard.
  • Expecting a program on a network share to open without extra access.

Run a program as another account step by step

  1. Open Command Prompt.
  2. Run runas /user:<computer>\<account> "<program>" with your own names.
  3. Type the password when Windows asks.
  4. Check that the program opened under the other account, then close it when done.

Related guides

To check which accounts exist first, see the net user command guide.

To make an account an administrator instead, see how to change an account to administrator.

To control the approval prompts, see how to change UAC settings.

Official sources

The syntax, switches, remarks and examples come from Microsoft’s runas reference.

The Secondary Logon and limitation notes also draw on Microsoft’s Run As feature article.

Leave a Reply

Your email address will not be published. Required fields are marked *