How to set up smartphones and PCs. Informational portal
  • home
  • Programs
  • Command line with administrator rights. RUNAS command - running an application as another Windows user

Command line with administrator rights. RUNAS command - running an application as another Windows user

Command line as Administrator - a mode for launching a command line utility in the Windows operating system with full administrative rights. The command line is a tool for performing administrative tasks on a computer without using a graphical interface.

The Command Prompt application runs in the Windows operating system in two modes: standard user or computer administrator. Command Prompt, launched as a Windows administrator, provides full access to execute any commands on the computer, unlike the standard user mode, where not all commands work.

When working on a computer, there is often a need to use the command line (cmd.exe) with elevated administrator rights. To apply certain system settings, you must have full administrative rights, for example, problems appeared on the computer, the user found a way to solve the problem, and for this you will need to use the command line.

To resolve the problem, run a command prompt with administrator rights and perform the necessary actions in the command line interface (command line interpreter).

In the instructions in this article, we will look at different ways to open the command prompt as an administrator in the Windows operating system: in Windows 10, in Windows 8.1, in Windows 8, in Windows 7. Here you will find 5 universal methods that work in all versions of Windows, and some methods that are only applicable to certain OS versions.

Run Command Prompt as Windows Administrator - Method 1

This method is suitable for all versions of Windows: Windows 10, Windows 8.1, Windows 8, Windows 7. To call the command line with full administrative privileges, use the search function in the operating system.

In Windows 7, go to the Start menu; in Windows 8 and Windows 8.1, move the mouse cursor to the top or bottom right edge of the Desktop; in Windows 10, the search field is located on the Taskbar.

  1. Enter the expression “cmd” or “command line” into the search field.
  2. Right-click on the application shown in the search results, select "Run as administrator".

How to enable the command line as administrator - method 2

The following method allows you to open the command line with full rights in different versions of the Windows operating system: launch the utility from the Start menu.

  1. Go to the Start menu (in Windows1 and Windows 8 you need to go to the Applications screen).
  2. Among the programs, in the “Utilities - Windows” folder (in Windows 7 - “Standard”), find the “Command Prompt” program.
  3. Right-click on the application, select "Run as administrator".

How to open the command line as administrator - method 3

There is another way to open Command Prompt as an administrator in any version of Windows. To do this, you will need to run the cmd.exe utility directly from the folder where it is located in the operating system.

  1. Open the system drive “C:” in Explorer.
  2. Enter the "Windows" folder, go to the "System32" folder.
  3. Right-click on the “cmd” application and select “Run as administrator” from the context menu.

How to run the command line with administrator rights - method 4

Another universal method that works in all versions of Windows, starting with Windows 8, is done using the Task Manager.

  1. Go to the "File" menu, select "Run new task".
  2. In the “Create a task” window, enter “cmd” (without quotes) in the open field, check the box next to “Create a task as administrator,” and then click the “OK” button.

Run the command line with administrator rights - method 5

In this method, we will create a special shortcut to launch the cmd.exe application with administrator rights.

  1. Enter the folder along the path: “C:\Windows\System32”.
  2. Right-click on the “cmd” application, select “Send” from the context menu, then “Desktop (create shortcut).”
  3. Right-click on the shortcut and select Properties.
  4. In the “Properties” window, in the “Shortcut” tab, click on the “Advanced...” button.
  5. In the “Advanced Properties” window, check the box next to “Run as administrator” and click the “OK” button.

Windows 10 Command Prompt as Administrator

In initial versions of Windows 10, you could easily access the Command Prompt. Then, Microsoft slightly changed its policy: instead of the command line, it is proposed to use Windows PowerShell (a more advanced analogue of the command line), so some methods of launching the command line no longer work in the operating system.

You can return the command line to its original place, instead of Windows PowerrShell, according to the instructions from the article.

  1. Press the “Win” + “X” keys at the same time.
  2. In the window that opens, you will see the “Command Prompt (Administrator)” item located in the same place.

Command Prompt as Administrator Windows 8.1

The easiest way to launch the command line in the Windows 10 operating system is from the Start menu on the Desktop.

  1. On the Desktop, right-click on the Start menu.
  2. In the menu that opens, click on “Command Prompt (Administrator).”

Command Prompt as Administrator Windows 8

This method works on Windows 8 and Windows 8.1 operating systems. In Windows 10 Explorer, instead of the command line, we are offered to use Windows PowerShell.

  1. Launch Windows Explorer.
  2. Log in to any drive or open any folder.
  3. In the Explorer window, left-click on the "File" menu.
  4. From the context menu, select first “Open Command Prompt” and then “Open Command Prompt as Administrator”.

Command Prompt as Administrator Windows 7

All the universal methods described in this article work in the Windows 7 operating system:

  • In the Start menu, type “cmd” or “command line”, right-click on the application, run as administrator.
  • Go to the “Start” menu, then “All Programs”, then “Accessories”, then “Command Prompt”, using the right button, launch the command prompt with administrator rights.
  • Run “cmd.exe” from the folder at the path: “C:\Windows\System32”.
  • Open a command prompt using a task in the Task Manager.
  • From a specially created shortcut on the Desktop.

Conclusions of the article

If necessary, the user can run the command line tool with full rights as an administrator in the Windows operating system. The article describes different ways to launch the command line as an administrator, working in operating systems: Windows 10, Windows 8.1, Windows 8, Windows 7.

To perform many of the commands that are mentioned in various articles, you must be able to open the Command Prompt as an administrator. In this short article you can familiarize yourself with several ways how this can be done in the Windows 7 operating system.

Opening the Command Prompt via the Start Menu

If you want to open the Command Prompt in Windows 7, the easiest way to do this is to use the Start menu. Open the Start menu and go to All Programs. Here you need to open “Standard”, where the command line shortcut is located. Simply by clicking on the “Command Prompt” icon, you will open it in normal mode, without administrator rights.

If you need to open the command line as an administrator, then right-click on the icon and select “Run as administrator” from the menu that appears.

After this, a warning from User Account Control will appear. To confirm opening the command prompt as an administrator, click on the “Yes” button.

As a result, a command line will appear in front of you. In order to make sure that it is opened as an administrator, pay attention to the window title. It should say "Administrator". Also, the “system32” folder should be open on the command line.

In addition to the All Programs menu, you can use Search, which is located at the bottom of the Start menu, to open the Command Prompt. Enter the search query “Command Prompt” and the system itself will offer you the desired shortcut.

Right-clicking also works in search results. With it, you can open the command prompt as an administrator.

In addition, some commands also work in the search bar. For example, you can open the command prompt using the "CMD" command.

Opening the Command Prompt via the Run menu

This is a small window that can be called up using the Windows + R key combination. Using this window, you can quickly execute various commands. For example, if you need to open a command prompt, you can press Windows+R and enter the command “CMD”.

As a result, a command prompt will open in front of you. Unfortunately, this way you can only open the Command Prompt in normal mode, without administrator rights.

Opening Command Prompt Using a Shortcut

If you regularly need to open the command line, the easiest way is to make a shortcut on your desktop. To do this, right-click on the desktop and select the menu item “Create – Shortcut”.

After this, you need to enter the “CMD” command, which is responsible for opening the command line, click on the “Next” button and confirm the creation of the shortcut by clicking on the “Finish” button.

As a result, a shortcut will appear on your desktop with which you can quickly open the command line at any time.

If necessary, you can right-click on the shortcut and open a command prompt as administrator.

If you want the shortcut to always be opened as an administrator, then you need to right-click on it and go to “Properties”. There, on the “Shortcut” tab, you need to click on the “Advanced” button.

After this, a window will open in which you need to enable the “Run as administrator” function.

After enabling this function, close all windows using the “Ok” button. Now, using this shortcut, the command prompt will always open as administrator.

    Team RunAS used to run an application under a user account whose name is passed as a command line parameter. In Windows 7 and later, this command, with standard security settings, does not allow you to gain administrative privileges, as happens in the "Run as Administrator" mode. To run the application as an administrator, you will need to perform some system settings. A universal way to run applications and batch files as an administrator without prompting UAC using the standard Task Scheduler is described in the article

RUNAS command line format:

RUNAS [ ] /user: username program

RUNAS [ ] /smartcard program

RUNAS /trustlevel: program trust level

Command line options:

/noprofile- Do not load user profile. This results in faster app loading times, but may cause some apps to not function properly.

/profile- Load user profile. This option is set by default.

/env- Use current environment settings.

/netonly- Credentials are for remote access only.

/savecred- Use credentials saved by the user. This option is not available in Windows 7 Home or Windows 7 Starter editions and will be ignored.

/smartcard- A smart card is used to provide credentials.

/user- username must be in the form USER@DOMAIN or DOMAIN\USER

/showtrustlevels- Display a list of trust levels that can be used as arguments to the /trustlevel parameter.

/trustlevel- The value "trust level" must be listed in the list of trust levels.

program- Command line for EXE. See examples below.

Examples:

runas /user:mymachine\administrator cmd.exe- run the command interpreter cmd.exe as the user "administrator" of the computer "mymachine". When executing the command, you will be prompted for the password of the user on whose behalf the task should be executed.

runas /noprofile /env /user:mydomain\admin " mmc %windir%\system32\diskmgmt.msc "- launch the mmc console with the Disk Management snap-in as the user "admin" in the domain "mydomain". The user profile is not loaded and the current environment variables are used. Loading a user profile is only necessary when there will be a task running that requires any data from it. If the "/env" parameter is specified, then environment variables are inherited from the current user's environment.

runas /savecred /user:admin@mydomain regedit.exe- run the registry editor "regedit.exe" as the user "admin" of the domain "mydomain" and remember the entered password. If the "/savecred" parameter is present, the entered password is stored in the registry in encrypted form and will not be requested in the future.

runas /showtrustlevel- display the levels of trust that exist in the system. The response will display a list like:

The following levels of trust are available in the system:
0x20000 (Regular user)

In addition to the trustlevel value equal to 0x20000 you can use the values 0x10000, corresponding to the minimum set of privileges and 0x40000, the standard set for this user. To view the differences between different trust levels, you can use the command Whoami, executing it in a shell session launched with each of the levels trustlevel

runas /trustlevel:0x20000 cmd.exe- run cmd.exe command processor using the trust level obtained in the previous example.

runas /trustlevel:0x40000 cmd.exe- run cmd.exe command processor using the standard trust level.

Note: In a command line session started using the /trustlevel parameter, the list of privileges corresponding to each trust level can be obtained using the command whoami/priv, and full account details are whoami/ALL

Note: parameter /profile incompatible with parameter /netonly.

Note: parameter /savecred incompatible with parameter /smartcard.

To run applications as administrator using runas.exe you need to change the default system security settings:

Enable the Administrator account (by default, it is disabled);

Set a password for the user Administrator;

To check for administrator rights, a batch file named who-admin.bat the following content:

WHOAMI/PRIV | find /i "SeRemoteShutdownPrivilege"

If %ERRORLEVEL% == 0 goto admin

Echo NOT have admin rights!

ECHO!!! ADMIN!!!

The principle of privilege analysis is based on the use of the command whoami with parameter /priv. Depending on whether you have administrator rights, the batch file displays the message "NOT have admin rights!", or - "!!! ADMIN !!!" and waits for a key to be pressed on the keyboard. Details can be found in the team description. whoami follow the link from the full list of commands.

runas /savecred /user:Administrator C:\scripts\who-amdmin.bat- run the batch file as administrator who-amdmin.bat, located in the C:\scripts folder. At the first launch, you will be prompted for the Administrator password, at subsequent launches (with the parameter /savecred) - no password required.

Passwords that are remembered when using the RUNAS.EXE utility with the /savecred parameter can be changed or deleted using the Saved Password Management snap-in:

%systemroot%\system32\rundll32.exe" keymgr.dll,KRShowKeyMgr

When typing key values, you must respect the case of characters.

To manage saved accounts in the Windows command line, use the utility CMDKEY.EXE

The command line (console) allows you to run programs, configure your computer, and automate many computer management actions. By default it runs with user rights. This protects the system from accidental changes and inexperienced users who, through their actions, can disrupt the operation of the system.

Therefore, in cases where major changes need to be made to the system, the command line must be launched with administrator rights. This will give full access to all operations and files. With administrator rights, you can execute any command in the console.

In this article, we will look at several ways to run the command line as an administrator in the Windows 7 and Windows 10 operating systems. It is unlikely that you will need all of these methods at once, just select the ones that are most convenient for you and use them if necessary.

Launching the Command Prompt Using Search

In the context menu of programs there is always a “Run as administrator” function. This function can be used on behalf of an administrator. To do this, open the Start menu and enter the “cmd” command into the search. After the command line (the “cmd.exe” file) appears in the search window, you need to right-click on it and select “Run as administrator” in the context menu that opens.

It should be noted that search in the Start menu works the same in both Windows 7 and Windows 10. Therefore, this method can be used in both of these systems.

After this you will see a warning about . Click on the “OK” button and the command line will open in front of you.

Also, the command line can be launched as an administrator without calling the context menu. To do this, open the Start menu and enter the command “cmd” into the search. After the command line (file “cmd.exe”) appears in the search window, you need to press the key combination CTRL+SHIFT+ENTER.

Launch the command line using the program list

In the Windows 7 operating system, the Command Prompt can be found in the menu in the “All Programs - Accessories” section. To run it as an administrator, call the context menu and select “Run as administrator.” After this, you will see a warning about running the program as an administrator. Click on the “Ok” button and a command line will open in front of you.

Due to differences in the design of the Start menu, this method will only work on Windows 7.

Executing a CMD command using the Run menu

Another option for opening a command prompt with administrator rights is to execute the “CMD” command in the “Run” menu. To do this, press the Windows key combination-R, enter the command “CMD” and press CTRL+SHIFT+ENTER. You need to run the command this way. If you simply press ENTER or the “OK” button, the console will start in normal mode.

You can also open the Run window from the Task Manager window, which is opened using CTRL-SHIFT-ESC or CTRL-ALT-DEL. To do this, open the "File" menu and select the "Run new task" option.

After this, the “Run” window will appear in which you can enable the “Create a task with administrator rights” option. When using this option, the “CMD” command will be launched immediately with administrator rights.

This option will work on both Windows 7 and Windows 10.

Create a command line shortcut

You can use a shortcut to run Command Prompt as an administrator. To do this, call the context menu on the Desktop and select “Create shortcut”.

In the window that opens, you need to enter the “cmd” command and click on the “Next” button.

After that, you need to enter the name of the shortcut and click on the “Done” button.

As a result, a shortcut to launch the command line should appear on your Desktop. Now open the properties of this shortcut and click on the “Advanced” button.

After that, close all windows by clicking on the “OK” button. That's it, after this, when you run this shortcut, the command line will be launched as administrator. This startup method works the same in both Windows 7 and Windows 10.

Opening a Command Prompt Using Windows-X

The Windows 10 operating system has an additional menu with a list of useful system utilities. There, among other things, there is a command line with and without admin rights. This menu can be opened using the Windows-X key combination or by right-clicking on the “Start” button.

In some cases, the entire command line in this menu is the PowerShell console. If this is the case for you, then you can switch to using the classic command line. To do this, open the “Options” menu, go to the “Personalization - Taskbar” section and turn off the “Replace the command line with Windows PowerShell” option.

The Windows-X menu is only available in Windows 10, so this method is only for this operating system.

Opening a command line from a folder

It is unlikely that this method should be used, but the command line can be launched from the “Windows\System32” folder (or from the “Windows\SysWOW64” folder if you have a 64-bit version of the operating system). To do this, go to the system drive, open the “Windows\System32” (or “Windows\SysWOW64”) folder and find the “cmd.exe” file in it.

The file “cmd.exe” is the Windows command line. To run it with administrator rights, right-click on it and select the “Run as administrator” option. You can also make a shortcut to cmd.exe on your desktop.

The location of the cmd.exe file does not differ between versions of Windows. Therefore, this method will work in both Windows 7 and Windows 10.

How to understand that CMD is running as administrator

After you have launched the command line, you should make sure that you did everything correctly and that it is running as administrator. To do this, you need to pay attention to the title of the window; it should contain the inscription “Administrator”, it indicates that the console is running as an administrator.

If there is no “Administrator” sign, then the console is working normally, close the console and try opening it again. If that doesn't work, you can try another opening method.

Often a situation arises when you need to run cmd with administrator rights. However, this is not so easy to do for an untrained user. The whole problem is that by default, cmd is launched as the current user; to run as an administrator, you either need to log into the system under the admin username, or do some trick.

There is a certain nuance that needs to be done before running the command line as an administrator. You need to check whether the administrator account is enabled, if it is enabled, assign a password to it. Now let's take a closer look.

First, you need to check whether your administrator account is enabled. To do this, open “ Computer management

go to the item “ Local users and groups” — “Users“. As you can see, in my case the account “ Administrator” is disabled (there is an arrow on the icon).

Double-click to open the account properties and uncheck the “ Disable account

Click “ OK“. The arrow from the admin account icon has disappeared, which means it is enabled. Now let's set a password. To do this, right-click on the account “ Administrator” and select the menu item “ Set password...

On the password change warning, click “ Continue” and enter the password twice

Ready! You now have an administrator account and know the password for it. Let's move on to the next stage.

Launch CMD with administrator rights

Open the command line by clicking “ Start” — “Execute“, or keyboard shortcut “ Win+R” and enter the command cmd. In the window that opens, write the following:

runas /profile /user:mymachine\Administrator cmd

(Where mymachine– this is the name of your computer)

and press Enter. The Command Prompt will ask you for an administrator password, enter it and wait for Command Prompt to launch with administrator rights. Everything would be fine, but after entering I got an error:

This error can appear in two cases. The first is that you entered the wrong password. Second, I have never logged in under an administrator account (my version).

You need to log out and log in as an administrator, so that's what I did

You can now log out and log in again using your account. Once you are logged in with your account, try running cmd again as an administrator.

And voila! A second command prompt window opened under the administrator account. Now you can browse directories, and even run applications as an administrator.

Best articles on the topic