Run as administrator feature is very important on windows, it protects your Windows OS from security risks. This article will tell you how to run cmd as administrator both in graphical user interface and command line. The method can be used to run PowerShell as administrator and other windows programs also.
1. Run As Administrator From Start Menu.
- In windows 10, expand Windows System folder from Start menu, then right-click Command Prompt (dos cmd window), click More —> Run as administrator menu item. Click Yes in the next popup User Account Control dialog, now it will open the Command Prompt window with administrator privileges.
2.Run As Administrator From Windows Explorer.
- Click Open file location menu item in the above example, then it will open the Command Prompt program saved directory in a windows explorer.
- Right-click the Command Prompt shortcut, then click Run as administrator menu item in the popup menu list.
3.Run As Administrator From Command-Line.
- Open a terminal and run command runas /user:Administrator “windows-program-path”.
runas /user:Administrator "C:\Java\jdk1.8.0_231\bin\java" Enter the password for Administrator: Attempting to start C:\Java\jdk1.8.0_231\bin\java as user "DESKTOP-Q26A5F3\Administrator" ... RUNAS ERROR: Unable to run - C:\Java\jdk1.8.0_231\bin\java 1326: The user name or password is incorrect.
- Whatever password you input, you may encounter the above error which said The user name or password is incorrect. This is because the Windows Administrator account is disabled by default, you need to enable it and set a password for it before using it.
- If you want to run the Windows program with another user account, just use the other user’s name to replace name Administrator in command runas /user:Administrator “windows-program-path” like below.
runas /user:Jerry "C:\Java\jdk1.8.0_231\bin\java"
4. Always Run A Program As Administrator.
- If you want to run a Windows program with administrator privileges for every time, you can follow below steps.
- Right-click the Windows program executable file in Windows Explorer.
- Click the Properties menu item at the end of the popup menu list.
- In the pop-up dialog, click the Compatibility tab, then check the Run this program as administrator checkbox at the bottom of the dialog.
- Click the OK and Apply button to save the changes.
- Now when you run it each time, it will popup the User Account Control dialog and run it with administrator privileges.