Skip to content

Windows RUNAS command

The Windows runas command allows users to run programs as a different user in the command line. It provides a way to execute applications with elevated permissions or under a different user account without having to log out and log back in. By using the runas command, users can perform tasks that require administrative privileges or access resources that are only available to specific users. The syntax of the runas command includes the program or command to be run, along with the username and password of the target user account. This command can be particularly useful in situations where a user needs to run programs with different levels of access or switch between user accounts seamlessly in a Windows environment.

RUNAS Syntax:

Terminal window
runas [/profile | /env] [/netonly] [/savecred | /netonly] [/smartcard] [/showtrustlevels] [/trustlevel] /user:UserName Program
runas /trustlevel:TrustLevel /profile /env /netonly /savecred /smartcard /showtrustlevels /user:UserEmail Program

Options:

OptionDescription
/profileLoads the user’s profile
/envUses current environment instead of user’s
/netonlyIndicates credentials are for remote access
/savecredSaves credentials for future use
/smartcardIndicates the password is a smartcard
/showtrustlevelsDisplays a list of available trust levels
/trustlevelSpecifies the trust level

Parameters:

ParameterDescription
UserNameThe user name for the account to be used
ProgramThe program to be executed with elevated privileges
UserEmailThe email address for the account to be used
TrustLevelThe trust level to be used for elevation

RUNAS Usage:

Run Command Prompt as a Different User

Terminal window
runas /user:DOMAIN\username cmd

Opens a new Command Prompt window running as a different user specified by the “DOMAIN\username”.

Run PowerShell Script as Another User

Terminal window
runas /user:username powershell.exe -file C:\Scripts\script.ps1

Executes a PowerShell script (“script.ps1”) as another user specified by “username”.

Run a Program as an Administrator

Terminal window
runas /user:username "C:\Program Files\Application\app.exe"

Launches a program (“app.exe”) as an administrator with a specific user account “username”.

Run Task Manager with Different Credentials

Terminal window
runas /user:Administrator "taskmgr.exe"

Starts the Task Manager as an administrator using the built-in Administrator account.

Common Questions on RUNAS Usage:

How do I use runas in Windows?

To use the runas command in Windows, execute the following command:

Terminal window
runas --option <value>

How can I run a program as a different user using runas?

To run a program as a different user in Windows using runas, use the following command:

Terminal window
runas /user:Domain\Username "C:\Path\To\Program.exe"

How to run a command prompt as an administrator with runas?

To open a command prompt as an administrator using runas, you can use the following command:

Terminal window
runas /user:Administrator "cmd"

Can I use runas with a specific profile or account in Windows?

Yes, you can specify a specific profile or account when using runas in Windows. Use the following command:

Terminal window
runas /profile /user:Domain\Username "C:\Path\To\Program.exe"

How to provide a password when using runas in Windows?

When using runas in Windows and prompted for a password, enter the password corresponding to the specified user account to proceed with the command execution securely.

Is it possible to run a batch script with elevated permissions using runas?

Yes, you can run a batch script with elevated permissions in Windows using runas. Use the following command:

Terminal window
runas /user:Domain\Username "C:\Path\To\Script.bat"

Applications of the RUNAS Command

  • Running a program as a different user
  • Running a program with elevated privileges
  • Executing commands with different credentials
  • Running scripts and batch files as another user