Runas is an extremely useful command on Windows. This command enables you to run a command in the context of another user account. One example where this can be useful is: Suppose you have both a normal user account and an administrator account on a Windows PC and currently you are logged in as a normal user account. Now, you want to install several software on the computer, but as you do not have admin privileges you cannot install the same from the current account.
One choice is to turn users and login as an administrator. Instead, you are able to do the same by using runas command. You only need to launch the installer from command prompt by using runas command and by giving administrator login id and password.
Rnas is a Command Line tool which is built into Windows Vista. To use runas at the command line, you are able to open a command prompt, then type runas with the appropriate parameters, and simply press Enter. Now, let us see the syntax of runas command with some examples!
RUNNING A PROGRAM FROM ANOTHER USER ACCOUNT
To run a program by using another user, you have to use the command below.
runas /user:domainname\ username program
For example, if you want to open a registry editor as administrator of the Windows PC, use the command below.
runas / user:administrator. regedit
After running the command above, you are going to be asked to enter the password of the administrator account. When password validation, next the registry editor is going to be opened with the administrator account.
If you want to give arguments to the program which need to be invoked as another user, you are able to put the program name and the parameters in double quotes.
RUNNING COMMAND PROMPT AS ANOTHER USER
If you have multiple commands required to be executed with administrator or any other user, instead of running each command using runas, you are able to open the command prompt window when you are an administrator. Then, you will be able to run all the commands in the window. In the text below is the command for opening a command window using runas.
runas /user:administrator cmd
RUN A BATCH FOLDER AS ADMINISTRATOR
For running a batch folder as administrator, you must tag or mention the path of the batch folder in the runas syntax.
In an example, to run the batch of folder that located at c:\data\mybatchfolder.bat, you have to run the command below:
runas / user:administrator C: \data\ mybatchfolder.bat
WAYS TO RUN A PROGRAM ON WINDOWS AS AN ADMINISTRATOR
You are able to launch a program as an administrator by right clicking on the executable file and selecting Run as administrator. As an alternative, pressing Shift + Ctrl while double clicking the file can also start the program as an admin. Pressing only Shift while you right-click on the file is going to add run as a different user to the context menu that opens a screen where you are able to enter another user’s credentials include the administrator account. For note: The username is Administrator and may not have a password if you have not applied one.
Also, these locations have shortcuts to admin access…
- Start Menu
Right-click an executable like anywhere for the option to launch a program as an administrator.
- Taskbar
Click a program on your taskbar to open the jump list, then simply right-click the exe from that menu for the admin option.
- File Explorer
Choose the file in File Explorer, and then click Manage in the Ribbon menu up top. Select “Run as administrator.”
- Run prompt
Submit this line into Run (Windows key + R).
- Command Prompt
From the command line, submit this with your file location.
- Task Manager
Click File -> Run new task -> Check the box next to “Create this task with administrative privileges” -> Submit the location of your file.
- Task Scheduler
When making a new task (Action -> Create Task), enable these settings in the “General” tab: “Run whether user is logged on or not” and “Run with the highest privileges”
For note: the Command Prompt method did not work until we enabled the Administrator account and changed another setting that will offer the command to be entered without a password.
SETTING PROGRAMS TO ALWAYS START AS AN ADMIN
Based on the research, Microsoft provides programs with the least amount of access possible, configuring an application to always run as an administrator is commonly not recommended but sometimes convenient when the software always needs elevation so you do not have to jump through those hoops every time. Here are a few ways to accomplish that:
Always run as admin from a shortcut:
Firstly, you have to right-click on a shortcut file -> Shortcut tab -> Advanced -> Check the box to “Run as administrator.”
Remember that you are able to make a shortcut file by right-clicking the main exe.
Always run as admin via Compatibility Properties:
Please right-click on an exe -> Properties -> Compatibility tab -> Check the box to “Run this program as an administrator.”
ALWAYS RUN AS ADMIN VIA THE REGISTRY EDITOR
Apparently, there are some steps that you have to do when you want to always run as admin via the registry editor. To do that, simply you are able to follow these steps below:
- At the first step, you need to locate HKEY_CURRENT_USER\ Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\ Layers
- If layers are missing, you have to right-click AppCompatFlags and then add a new key named Layers.
- Now, you are able to right-click layers (either the folder or in the right pane) and create a new String Value.
- In this step, you need to set the value name as the full path of the exe file
- The last step that you have to do is to set value data as ~ RUNASADMIN
AUTHOR BIO
On my daily job, I am a software engineer, programmer & computer technician. My passion is assembling PC hardware, studying Operating System and all things related to computers technology. I also love to make short films for YouTube as a producer. More at about me…
Leave a Reply