≡ Menu

Windows runas command syntax and examples

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 both a normal user account and an administrator account on a computer and currently you are logged in as 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


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.

42 comments… add one
  • Rakesh

    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?

    • n. sharma

      I’m encountering the same problem. Did u get the solution.
      Please help me.

    • Ray

      If rakesh is the administrator, then the command would be runas /user:rakesh cmd

    • Stuart

      Hi Rakesh,

      Administrator is the name of a specific, built-in account – not a pseudonym for any administrator account, or the Rakesh account. The error you are receiving is due to the Administrator account having a different password to the Rakesh account, so inputting the Rakesh password does not authenticate correctly.

    • Ab.K.F


      runas /user:computername\rakesh cmd

      Substitute “computername” with your computer name. To find your computer name, press either of the following:

      – WindowsKey+Fn+PauseBreak
      – WindowsKey+PauseBreak

    • SK

      runas /user:\ cmd

      So if you want the run the ‘Superadmin’ account for your domain that is called ‘Beefpower’ you would enter.

      runas /user:beefpower\superadmin cmd

      That would tell the computer to request a signin for the account named superadmin on the beefpower domain.

      To log into with a local account you can substitute the name of the computer with a period.

      So if the computer name was noodlepower you could use
      runas /user:.\administrator cmd

      .\administrator would substitute the period for the name of the computer you are currently logged into.

      By default the computer will use a local account, but this has it’s uses. Mostly when you are trying to log on as a local account when a domain account is listed at the login screen or you don’t know or want to type the terrible default names Microsoft assigns computers.

    • Admin

      Hey, Try to reset your Pc Bios, It happened to me before on my mom’s laptop.

    • Avinash
  • Techblogger

    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.

    • tecthusiast

      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.

    • s.smits.nl

      I’ve the exact same problem as tecthusiast described

      No solution what so ever either

  • tecthusiast

    oh and no im not connected to a domain

  • Jeff

    I’m trying to add a new user using runas, it does not work.

    C:\Users\jeff>runas /user:domain\jeff "net user /add newuser password "
    Enter the password for domain\jeff:
    Attempting to start net user /add newuser password as user "domain\jeff" ...

    A new command window flashes and it does not print any error in the main window. But I don’t see the user added.

    • Tyler

      Try chnage
      net user /add newuser password
      net user newuser password /add
      It should work

    • CJ Goggin

      runas /user:domain\jeff “net user /add newuser password ”
      should the syntax be “net user newuser password /add”

  • Tyler

    I have RUNAS in my batch script and I’ve got a problem.
    First call of RUNAS works fine, but second call (after some other commands) doesn’t work. It starts program with current user, not with user I specified in RUNAS command.
    Why so?

  • Lyle

    When attempting this command, I receive the message “Enter the password for the administrator:”, which obviously I do not have, or I wouldn’t be going to this amount of trouble.
    Additionally, my command does not go straight to “C:\runas…”
    Rather, it automatically goes C:\Users\(my username)>runas, which seems like it may be the problem that sparks the program to ask for the administrator password.
    (Yes, my computer has parental controls on it which I am attempting to bypass. It is important to note that no, parents do not always have your “best interests” in mind, and as this laptop is my primary means through which I complete schoolwork I need to be able to install programs and update them at will, without needing to beg for a password. It is not nearly as simple as “just ask your parents” or “be responsible and show them you can handle it” for some people, and I do not have the time to argue with a parent whenever I need to install a program such as Evernote or change some small setting such as which programs are displayed in the taskbar.)

    • Dan S.

      I think your not understanding the command at all. The runas command is setup to allow you to run applications or the command prompt with an admin password for that machine without having to switch who is logged in. If I (your dad has admin rights to the laptop) then If I ran the runas command I could use my credentials to install or run something with admin right on your profile. So you have to have the administrator password or a users password that has admin rights to run this. You would need a different program for what you are trying to do. You would need a way to get the admin password or a way to login with admin rights.

    • grummbunger

      think like a hacker and with a hidden video cam watching you get your dad to enter the password for whatever reason you can get that he will do and capture that password. to hack is not always via computer code….

    • Jungle


      It looks like your parents have created a user account for you which has less privileges (standard user). You might want to look at it another way. Lets say, you can change the Administrator password to nothing (blank) and move your user account under Administrators group (but make sure the Operating System is not Home Basic or any such lower tier OS ).
      You might want to use the “net user” command.
      First of all, do the following to change the admin password. in command prompt, type “net user Administrator *” and press enter-type a new password as required and confirm by re-typing it . Then type “runas /user:Administrator cmd”. this will open command prompt in admin mode
      1. in command prompt type, “net users” and press enter . identify your username and take not of the administrator user account
      2. type “net localgroup users” or try “net localgoup Administrators” and press enter to see which local group your user account is in. make sure you remember your username
      3. type “net localgroup Administrators {your username} /add” and press enter
      4. type “net localgroup Administrators” to confirm that your username is now under administrators group. You should now have full admin privileges to do the unthinkable.

      You might also, as a way of courtesy , not tell your parents what happened to the admin password.

      Happy learning!

  • Wissam

    the runas asked the user to insert the password, what if i want to ask to insert the user name and the passweord

  • gdv

    I used to be able to run the following two commands from the Run window (WinKey+R) in WinXP, but on Win7 the second command (delete arpcache) requires elevation (Run as administrator), even when launched from the Run window under an admin user acct:

    cmd /k ipconfig /flushdns
    cmd /k netsh interface ip delete arpcache

    I understand the basics of UAC, and from what I gather from numerous forum threads and several experiments of my own, there is simply no way to run the second command directly from the Run window (short of creating a batch file to run a “scheduled task” and running the batch file from the Run window).

    I thought maybe there would be a way to do this using Runas, but have not succeeded yet. At best, it appears I can only open an elevated Command Window using Runas, then still have to enter the “netsh interface ip delete arpcache” command in that elevated window. (…in which case, WinKey > type “cmd” > Ctrl+Shift+Enter is faster to open an elevated command window than using Runas from the Run window)

    Am I overlooking something? Is there any way to do this with a single Runas command from the Run window (WinKey+R) without using a batch file?

    (The advantage would be that the command would be stored in RunMRU, readily available for re-use in the Run window, and I can propagate it along with other favorite RunMRU commands to other computers via REG file.)


  • Mariela

    I need to put the password in the same command line. How can I do that?

    • Rand L Petersen

      Thanks for your input, however my problem is that after running “runas/user:administrator regedit” (or regedit.exe) my console asks for administrator’s password BUT WILL NOT ACCEPT input, the cursor just sits there and WILL NOT accept keystroke entries! Please help.

  • Leeroy

    How can I use this in batch files without creating a new window?

    Sort of like this, but this doesn’t work:

    @echo off
    title Ugly title with Administrator: prepended to it
    runas /trustlevel:0x20000 %0 %*
  • peter

    i have 3 user on my pc and for the one i need to log into i can not cause i forgot the password
    right now i m using guest and i am trying to reset password for the one i need to be log into iv search on youtube of how i can get into my main user ?
    administrator peter norton jr guest
    my main user is the peter norton jr but i forgot the password ?
    i tried the cmd prompt but cannot reset/change password doing something wrong?
    thank you

  • peter

    i also dont know the password for administrator or for peter norton jr
    tried sereval command prompts on how to change or reset password

  • algren

    hey, i tried for run this command which i have been create new user account before it’s called “backdoor” and password “backdoor”

    runas /user:administrator\backdoor regedit

    and i have a problem with error 740: The requested operation requires elevation.

    anyone can help me?

  • Elia

    How would I use runas in which the command and the arguments both have spaces, e.g., something like:

    runas /user:username "\"C:\Program Files\path\testit.bat\" \"first argument\"" 

    If the argument(s) don’t have spaces and don’t need quotes, then there is no issue and it runs, e.g.,

    runas /user:username "\"C:\Program Files\path\testit.bat\" argument"

    Or if the command does not have spaces, but the argument(s) do, then there is also no issue, e.g.,

    runas /user:username "C:\temp\testit.bat \"first argument\""

    However, when both the command and the argument(s) have spaces and need to be quoted, then it will not run.

    Note that I was able to get this to work using cmd as a wrapper so that the actual command to runas does not have spaces, but the syntax was even more ugly and contorted than above, e.g.,

    runas /user:username "cmd /Q /C \"\"C:\Program Files\path\testit.bat\" \"first argument\"\""

    Any suggestions to get this to work with the extra cmd wrapper?

    • Elia

      Correction to my question:
      Any suggestions to get this to work WITHOUT the extra cmd wrapper?

  • Benit

    Hi I am trying to launch my application using runas command using the following syntax
    runas /user:xxxx “c:\application.exe D:\” the first path is the application which i need to launch and the second command argument is the input to the launched application. But right now , it is showing error msg in ProcessShellCommand(cmdInfo) . Please suggest some alternatives

  • Roberto

    Hi, I have a service that run some scripts with administrator privileges, but the scripts work only if it was run by a simple user.
    I have change the account connection of the service, but the scripts keep been launch with administrator privileges.
    So how can I run it?

  • chris


    Is there a way to have the command line script launch as admin and enter the password without typing it in manually?

    • Gert

      Have you found a resolution as yet?
      I am also looking for a solution to enter a password automatically.

  • Logan Roy

    Hey I made the runas batch file but when the cmd-like window opens up I am unable to type in any text for the administrator password. Any thoughts?

    • cubedj

      it just isn’t showing any placeholder characters for what you’re typing in… so it only seems like it’s not working ;)

  • Naresh


    I have batch file which make changes to the local machine host file. This batch needs to be run with a local administrative user. I have the user name and password both. How can I put this in a batch file so that batch file execute using the run as different user and don’t ask for the password from user because they would not have the password.


  • Avi

    What are the relations among RUNAS TAKEOWN ICACLS gpedit.msc ATTRIB
    took me a long time to delete a folder playing with all this new and old commands

  • Ashik

    I would like to install a bat file in user’s PC in server environment. bat file is saved in desktop of the user account. I want to install it with the user login
    Please advise about the cmd comments

  • I have tried the below, but not sure if my actual script is working though to launch wordpad as admin and capture the password directly.

    start RUNAS /User:domain\username PASSWORD:abcd123 wordpad.exe

    Any suggestions if someone else got this working?

  • Krishna

    Is there a way to have the command line script launch as different user and enter the password without typing it in manually? using runas or any other command?

  • adonios77

    Open a Administrator Command Prompt as [Administrator: C:\Windows\system32\cmd.exe]
    Command Prompt Code:
    PowerShell.exe -windowstyle hidden -Command “Start-Process cmd.exe -ArgumentList ‘/s,/k,pushd,%windir%\system32’ -Verb RunAs”

Leave a Comment