The Example of Windows Runas Command Syntax

What is Runas? It is a command which is useful on Windows OS. If you use this command, it will be able to permit one to run a command in the context of another user account. Let’s take an example of the usage of it.

Let’s say that you have a normal user account and also an administrator account on a computer. And now, you are logged in as a normal user account. However, you want to install some software on the computer but because you do not have admin privileges, so you are not able to do that.

But, you will be able to do that if you use Runas command. With Runas, you just have to launch the installer from the command prompt and by providing administrator login id and password.

Runas Command Syntax and the Examples

What are the syntax commands? If you want to know about it, here, we will inform you about it including with some examples. If you want to run a program from another user account, you are able to use this command:

runas /user:domainname\username program

Let’s take an example. If you want to open registry editor as administrator of the computer, the command will be like this:

runas /user:administrator regedit

If you have run the command above, then you will be asked to insert the password of the administrator account. After the validation of the password, the registry editor will be opened with the administrator account credentials.

Now, how to specify arguments to the program? In case you wish to provide arguments to the programs that must be invoked as another user, you are able to put the name of the program and also the parameters in the double quotes.

What command do we can use if we have a lot of commands to be executed with administrator credentials? If you have a lot of commands that must be executed with administrator credentials, you do not have to run each command using runas.

You are able to open the command prompt window once as the administrator and then you are able to run all the commands in that window. So, here is the command that you are able to use for opening a command window using runas.

Runas /user:administrator cmd

And here are the examples:

C:\>runas /user:administrator cmd

Enter the password for administrator:

Attempting to start cmd as user “techblogger-pc\administrator” …

It will launch a new window of command after printing the message above.

Now, how about running a batch file as administrator? In case you wish to run a batch file as administrator of the computer, you will need to mention the path of the batch file in the place of command in the syntax of runas. Let’s take an example. If you want to run the batch file which is located at c:\data\mybatchfile.bat, you have to run the command that you are able to see below.

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

Talking about the usage of runas command and also the examples of the usage of it, of course sometimes some people find a problem when they try to use it. One of the problems may be found by people is that when they use the runas command, they get an error which says that this program is blocked by group policy. In addition, in that error message, it is also written that for more information we are able to contact our system administrator. If we find this issue, how to fix it? Are there any ways that we can do to try to fix this issue?

Well, in case you find this kind of issue, the administrator of your system may have disabled users to login from command prompt. In the group policy editor, the setting is able to be found in the node below.

Computer Configuration -> Windows Settings -> Security settings -> Local Policies -> User rights assignments

In the path above, you have to find the setting which says Deny Logon As A Batch Job. In case you have administrator privileges, you are able to disable this settings. Or, you have to contact the system or domain administrator.

About Runas Command

What is Runas? It is a command-line tool which is built into Windows Vista. If you want to use this tool at the command line, you have to open a command prompt and then you have to type runas with the appropriate parameters and at last press the Enter button.

For your information, according to the Windows site, in the user interface for Windows Vista, the Run as… command has been changed to Run as administrator command because Windows Vista will prompt you automatically for an administrator password when it is needed.

Runas applies to Windows Vista, Windows XP, Windows Server 2003, Windows HPC Server 2008 R2, Windows Server 2008, Windows Server 2003 R2, Windows Server 2000, Windows 7, Windows Server 2012, Windows Server 2003 with SP1, Windows 8.

Here are some of the parameters.

  • /profile

It loads the profile of the user and it is the default. This parameter cannot be used with the /netonlyl parameter.

  • /no profile

It can specify that the profile of the user is not to be loaded. It permits the application to be able to load more quickly. However, it can also cause a malfunction in some applications.

  • /env

It can specify that the current network environment be used instead of the local environment of the user.

  • /savecred

It indicates if the credentials have been saved by this user previously. On Windows Vista Home, this parameter is not available and Windows Vista Starter Editions will be ignored. Also, this parameter is not able to be used with the /smartcard parameter.

  • /netonly

It indicates that the user information specified is for remote access only and this parameter is not able to be used with the /profile parameter.

  • /smartcard

This parameter indicates whether the credentials are to be supplied from a smartcard. It is not able to be used with the /savecred parameter.

  • showtrustlevels

This parameter shows the trust level which is able to be used as arguments to /trustlevel.

Leave a Reply

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