runas - Run as a different user

Maintained on
Table of Contents

The runas command starts a program as a different user account from the one you are currently signed in with.

Use it when you normally work as a standard user but need to run one task with an administrator account, or when you want to run a tool with a domain account.

Basic syntax of runas

runas /user:<user name> "<program to run>"

For /user, specify the account to run as. Use user@domain or domain\user for a domain account, and computername\user for a local account. The user@domain form (UPN) works only for domain accounts.

Enclose the program to start in double quotation marks.

Start Command Prompt as another user

The most basic use is to start Command Prompt as a different user.

runas /user:PC01\admin2 cmd
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>runas /user:PC01\admin2 cmd
Enter the password for PC01\admin2:
C:\users\user>

After you type the password and press Enter, a Command Prompt for that user opens in a new window. The password is not displayed as you type.

Run whoami in that window to confirm which user it is running as.

Run a program with arguments or spaces in the path

If you want to pass arguments, or the path contains spaces, enclose the whole command in double quotation marks and write the inner double quotation marks as \".

Open
runas /user:PC01\admin2 "notepad C:\work\memo.txt"
Run
runas /user:PC01\admin2 "\"C:\Program Files\MyTool\tool.exe\" /option"
Tip

If the quotation marks do not work, put the program in a path without spaces, or first open a Command Prompt with runas /user:... cmd and run the program from there. This makes quoting problems easier to avoid.

Option reference

OptionDescription
/user:<user name>Specifies the user account to run as (required)
/profileLoads the user profile (default)
/noprofileDoes not load the user profile. Starts faster, but some apps do not work
/envUses the current environment (such as environment variables) instead of the user’s own
/netonlyUses the specified credentials only for remote access over the network
/savecredSaves the credentials so you do not have to type the password again
/smartcardSpecifies the credentials with a smart card
/savecred is not available on Windows Home editions

/savecred cannot be used on Windows Home editions. It can be used on editions other than Home.

Use different credentials for network access only with /netonly

With /netonly, local programs keep running as your current user, and the specified account is used only when connecting to shared folders or servers on the network.

runas /netonly /user:CORP\taro cmd

This is handy when you need to reach a file server in another domain but your PC does not belong to that domain. The local user does not change, so whoami still shows the original user.

With /netonly, the credentials are not verified when the program starts. Even if you mistype the password, the program starts, and you get an error only when you actually connect to a shared folder or similar.

You cannot put the password in a batch file

runas has no option for passing the password on the command line. It always prompts for it, so writing runas in a batch file cannot automate the password entry.

If you really want to skip typing it, you can:

  • Register a task in Task Scheduler (schtasks) with the user to run as
  • Use /savecred to store the credentials (read the warning below first)
Be careful with /savecred

Credentials saved with /savecred are stored on that computer. After that, anyone signed in with the same Windows account can run programs as that user without a password. Never use it with administrator accounts on shared PCs or in environments others can access.

When you want to run as administrator

If you specify another account that has administrator rights, the program runs with that account’s rights. Depending on your UAC settings, it may start with a restricted, non-elevated token.

runas /user:PC01\Administrator cmd

However, specifying your own current user does not elevate to administrator rights. To run as an administrator with your current account, open Command Prompt with “Run as administrator”.

The built-in Administrator account

The built-in Administrator account in Windows 10 / 11 is disabled by default. If you have not enabled it, you cannot sign in with it.

Common errors

Message / error numberMain cause and fix
Error 1326 (user name or password is incorrect)Check the spelling of the user name, the domain name, and the password
Error 1327 (account restriction)Accounts with an empty password cannot be used by default. Set a password
Error 1058 (the service cannot be started)The Secondary Logon service is disabled. Enable and start the service
“The system cannot find the file specified”Check the program path and how you quoted it

You can check the state of the Secondary Logon service with sc query seclogon.

sc query seclogon

Summary

GoalCommand
Run a program as another userrunas /user:user "program"
Open Command Prompt as another userrunas /user:user cmd
Use other credentials for network access onlyrunas /netonly /user:user cmd
Save credentials to skip typing them next timerunas /savecred /user:user "..."
Check which user you are running aswhoami

Practice questions

Practice Problem

How can you specify the password with the runas command?

Choose one answer.

  1. With the /password: option
  2. You cannot specify it on the command line; you are prompted when it runs
  3. In the form /user:user:password

Practice Problem

Which option do you use to keep local programs running as your current user and use different credentials only for network connections?

Choose one answer.

  1. /savecred
  2. /netonly
  3. /noprofile
#Command Prompt #Batch files #Command line #Command #User #Administrator rights