Runas is a very useful command on Windows OS. This command enables one to run a command in the context of another user account. One example scenario where this could be useful is: Suppose you have a normal user account and an administrator account on a computer and currently you are working from the normal user account. Now you want to install some software on the computer, but as you do not have admin privileges you can’t install the same from the current account. One option is to switch user and login as administrator. Instead, you can do the same by simply using runas command. You just need to launch the installer from command prompt using runas command and by providing administrator login id and password.
Let’s see the syntax of runas command with some examples.
Run a program from another user account
The command to launch a program using another user credentials is given below.
runas /user:domainname\username program
For example, if you want to open registry editor as administrator of the computer, the command would be as below.
runas /user:administrator regedit
After running the above command, you will be asked to enter the password of administrator account. After password validation, registry editor will be opened with the administrator account credentials.
To specify arguments to the program:
If you need to provide arguments to the program that need to be invoked as another user, you can put the program name and the parameters in double quotes.
runas /user:username "program argument1 argument2 ..."
For example to open the file C:\boot.ini as administrator, the command would be:
runas /user:administrator "notepad C:\boot.ini"
Running command prompt as another user :
If you have multiple commands need to be executed with administrator(or any other user )credentials, instead of running each command using runas, you can open command prompt window once as the administrator and then run all the commands in that window. Below is the command for opening a command window using runas.
runas /user:administrator cmd
Example:
C:\>runas /user:administrator cmd Enter the password for administrator: Attempting to start cmd as user "techblogger-pc\administrator" ...
It will launch new command window after printing the above message.
Run a batch file as administrator
To run a batch file as administrator of the computer, you need to mention the path of the batch file in the place of command in the runas syntax.
For example, to run the batch file located at c:\data\mybatchfile.bat, you need to run the below command.
runas /user:administrator C:\data\mybatchfile.bat
Some questions regarding runas command:
When I use runas command, I am getting the error ‘This program is blocked by group policy. For more information, contact your system administrator’. How can I fix this?
Administrator of your system might have disabled users to login from command prompt. In group policy editor, this setting can be found in the below node.
Computer Configuration -> Windows settings -> Security settings ->Local Policies -> User rights assignment
In the above path, look for the setting ‘Deny logon as a batch job‘. If you have administrator privileges, you can disable this settings. Otherwise, you need to contact the system/domain administrator.
{ 5 comments… read them below or add one }
Unable to runas administrator.
I have only one user 'rakesh' and that user is the Administrator. When I execute this command -
C:\Users\rakesh>runas /user:administrator cmd
Enter the password for administrator:
Attempting to start cmd as user "RAKESH-LAP\administrator" …
RUNAS ERROR: Unable to run – cmd
1327: Logon failure: user account restriction. Possible reasons are blank passwords not allowed, logon hour restrictions, or a policy restriction has been enforced.
I enter the password for user 'rakesh'. What am I missing here?
runas is useful if the current logged in account does not have admin access. In your case you already have admin privileges. why are you doing runas admin then?
Check if the administrator account is disabled, or the password has expired. 'Net user administrator' will show this info.
im having the same problem as Rakesh. regardless of whether or not im on admin already i would like a solution. i don’t care if i don’t need to do this to install something, this doesn’t work on limited users either.
before you ask yes Secondary Logon says: Status=started; Startup Type=Automatic; Log On As=Local System.
yes i have tried changing the password from a blank, it doesn’t accept it otherwise
what i want is to open another cmd shell as the built in administrator.
the error i get is:
RUNAS ERROR: Unable to run – cmd
1327: Logon failure: user account restriction. Possible reasons are blank passwords not allowed, logon hour restrictions, or a policy restriction has been enforced.
no administrator does not have logon hour restrictions
no policy restriction (to the best of my knowledge) is enabled, i’ve formatted this myself.
this problem i running me through the walls i would really apreciate any help that could gget this fixed thank you.
I’ve the exact same problem as tecthusiast described
No solution what so ever either
oh and no im not connected to a domain