Windows Runas Command Examples & Syntax

By | April 5, 2022

Using Runas on Windows Operating System can be very useful. A command can be run as another user using this command. Here’s a situation where this would be useful: Imagine you have two user accounts on a computer, an administrator account & a normal user account.

    • However, since you don’t have admin priorities on this machine, you cannot install any program using the present account. Logging in as an administrator is one option. Alternatively, you can use the run command to accomplish the same thing.

Windows Runas Command Examples & Syntax

  • Using the run command, you can install the program and provide the password and login information for administrators from the command line.

A few examples will help you understand the syntax of the rules command.

Read: Run Command for Device Manager – CMD from Admin

Use another user account to run a program:

Using the credentials of another user, you can launch a program.

runas /user:domainname\username program

As an example, You would issue the following command follows when you wish to open the administrator of the registry.

runas /user:administrator regedit
  • The earlier command will prompt you for the administrator’s password after being executed. Using the credentials for an administrator account, You will see the registry editor once the password has been validated.
  • Specify the following arguments: Double quotes can be used when there are several things you must do for other users with arguments about the program. There are two parameters in this program: should be enclosed within double quotation marks.
runas /user:username "program argument1 argument2 ..."

A user with administrative rights should open the doc: C:\boot.ini & following the command below:

runas /user:administrator "notepad C:\boot.ini"

As another user, run the command prompt:

Use runas instead of administrator credentials If you have more than one command that needs to be run simultaneously. It’s possible to run all commands in the Window once in the command prompt you’ve opened it as an administrator. Using runas, here is a simple command to open a command window.

runas /user:administrator cmd

Like as:

C:\>runas /user:administrator cmd
Enter the password for administrator:
Attempting to start cmd as user "techblogger-pc\administrator" ...

This message can be printed after printing it, it will open a new command window.

When you execute a batch file as administrator, you will see the following message:

In place of the command, you must specify the path of a batch file in the runas syntax in order for the batch file to be run as an administrator. For example, the following commands can be used how to run a batch file c:/data/mybatchfile.bat.

runas /user:administrator C:\data\mybatchfile.bat

The runas command raises the following questions:

  • It seems that group policy is blocking runas using the command. I would recommend contacting your system administrator. How can I resolve this issue?
  • You may have been prohibited from logging in to your system from the command prompt by the administrator of your system.

Under the below node, you will find the setting in the group policy editor.

Computer Configuration -> Windows settings -> Security settings ->Local Policies -> User rights assignment

Check the example ‘Deny logons as batch jobs’ in the path above. This setting can be disabled if you are an administrator. Administrators of systems and domains must be contacted otherwise.

You may also like: Mac Address From Command Line: Remote Computer [CMD]

Leave a Reply

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