All you have to do is use the runas
command to run your program as Administrator (with a caveat).
runas /user:Administrator "cmdName parameters"
In my case, this was
runas /user:Administrator "cmd.exe /C %CD%installer.cmd %CD%"
Note that you must use Quotation marks, else the runas command will gobble up the switch option to cmd.
Also note that the administrative shell (cmd.exe) starts up in the C:WindowsSystem32 folder. This isn’t what I wanted, but it was easy enough to pass in the current path to my installer, and to reference it using an absolute path.
Caveat: Enable the admin account
Using runas this way requires the administrative account to be enabled, which is not the default on Windows 7 or Vista. However, here is a great tutorial on how to enable it, in three different ways:
I myself enabled it by opening Administrative Tools, Local Security Policy, then navigating to Local PoliciesSecurity Options and changing the value of the Accounts: Administrative Account Status policy to Enabled, which is none of the three ways shown in the link.
An even easier way to accomplish this:
C:> net user Administrator /active:yes
Let’s consider several ways to run a program as an administrator in Windows 10 to fix errors: “CreateProcess failed; code 740“, “The requested operation requires elevation“, “Access is denied“, etc. that occur when running programs with limited rights (user, the guest).
By default, programs and games in Windows 10 run without administrator rights to prevent unauthorized changes to your system. But this is a common case when for the program to work correctly, it needs to be run with elevated rights (administrator), to work correctly or to execute certain commands.
⚠️ Attention: to run the program with elevated rights, you need to know the administrator password!
Content
- Application Icon
- File properties
- Start menu (context menu)
- Start menu (keyboard shortcut)
- Run menu
- Explorer Ribbon
- Windows Search
- Command prompt (CMD)
- PowerShell
- Batch file
Article in other languages:
🇪🇸 – Cómo ejecutar programa como administrador
🇷🇺 – Как запустить программу от имени администратора
🇫🇷 – Comment exécuter un programme en tant qu’administrateur
🇩🇪 – So führen Sie ein Programm als Administrator aus
🇳🇱 – Hoe Programma als administrator uitvoeren
🧐 It might be interesting:
1️⃣ 8 Ways to Run Command Prompt as Administrator
2️⃣ 7 Ways to Run PowerShell as Administrator
Application Icon
How to run the program as administrator once, using the program icon:
- Right click on the program icon;
- Select Run as administrator.
File properties
The method is to always run the program with administrator rights using the File Properties menu.
- Right click on the program icon;
- Select Properties;
- Open the Compatibility tab;
- Check the Run this program as an administrator box;
- Click OK.
This setting will allow this program to run continuously with elevated rights for that user only. If you want to allow the program to run with administrator rights for all computer users, in the previous window, click the Change settings for all users button and check the Run this program as an administrator box.
Run the program with elevated rights using the context menu in the Start menu.
- Open the Start menu (Ctrl+ESC);
- Find the program icon in the All Programs list;
- Right-click on the program icon, select: More -> Run as administrator.
In the same way, you can launch App Tiles in Windows 10, 8.
A mouse click and keyboard shortcut in the Start menu is another way to run program as administrator.
- Open the Start menu (Ctrl+ESC);
- Find the program icon in the All Programs list;
- Hold down the Ctrl+Shift keys and click on the program icon.
The way to run the program with full rights using the Run menu.
- Press the Windows+R key combination (or right-click on the Start button and select Run);
- Enter the command name or drag the program icon into the Run menu entry window;
- Press the keyboard shortcut Ctrl+Shift+Enter.
⭕ If you cannot move the program icon to the Run menu:
- Press and hold the Shift button, right-click on the program icon;
- Select Copy as path;
- Paste from the clipboard into the Run window (press the key combination Ctrl+V).
Explorer Ribbon
An easy way to run any program as administrator is using the Windows 10 Explorer ribbon.
🔔 If the Explorer Ribbon is not displayed in the folder menu, press Ctrl+F1.
- Select the program icon in Windows Explorer;
- In the folder menu, open the Application Tools tab;
- Select Run as administrator.
Windows Search
You can also run the program with administrator rights using Windows 10 Search.
- Press Windows+S (or right-click on the Start button and select Search);
- Enter the name of the required program;
- On the right side of the window, click Run as administrator.
Run program as administrator Command prompt (CMD)
One-time launch of the program as administrator – using the Windows command line (CMD).
An easy way to start is to run Command Prompt as administrator, from which the required program is launched. But you can also run from the CMD console (with user rights) using the runas command.
- Run Command Prompt;
- Run the runas command, specifying the username with administrative rights and the full path to the file of the program to be launched;
- Enter the password for the user with administrative rights.
runas /user:MHelp.pro "C:totalcmdTOTALCMD.EXE"
Run program as administrator using PowerShell
Another way to run the program with elevated rights is by using Microsoft PowerShell.
An easy way to start is to run PowerShell as administrator and run the required program. But you can also start from the PowerShell console (with user rights) using the start-process command.
- Start PowerShell;
- Run the start-process command, specifying the full path to the file of the program to be launched;
- Enter the password for the user with administrative rights.
start-process "C:totalcmdTOTALCMD.EXE" –verb runas
Batch file
In some cases, using the previous methods may be inconvenient, let’s create a bat file with instructions for running the program.
A batch file is a script file in DOS, OS/2 and Microsoft Windows. It consists of a series of commands to be executed by the command-line interpreter, stored in a plain text file.
Wikipedia
- Launch the standard Notepad application;
- We indicate the required sequence of commands;
- In the File menu, select the Save As item;
- In the File name field, specify the file name and add the .bat extension;
- In the File type field, specify All files;
- Click the Save button.
Now you can run the program with administrator rights by running the created file.
Find out more commands that can be used in bat files – link.
🟢 How to run the program as administrator was discussed in this article. I hope you now know how to fix error 740 or “The requested operation requires elevation” by running the program with elevated privileges in a convenient way. However, if you run into any problems while setting up, feel free to write in the comments. I will try to help.
- Remove From My Forums
-
Question
-
Hello All,
I would like to know if there is a way to run a java program, requiring administrator priviledges, via the Windows command line.
Normally you would right click and then select ‘run as administrator’ — but i would like to set this as a property on the command line, so that you dont have to right click every time. Is this possible?
Answers
-
Create a new txtfile, pase this content:
@echo Set objShell = CreateObject("Shell.Application") > %temp%sudo.tmp.vbs @echo args = Right("%*", (Len("%*") - Len("%1"))) >> %temp%sudo.tmp.vbs @echo objShell.ShellExecute "%1", args, "", "runas" >> %temp%sudo.tmp.vbs @cscript %temp%sudo.tmp.vbs
and save it as SUDO.cmd.
Now copy the cmd to your system32 folder.
When you now want to run a programm with admin rights type this:
sudo cmd /k javaw.exe JAVA file
Now accept the UAC prompt.
Hope this helps.
André
«A programmer is just a tool which converts caffeine into code» CLIP- Stellvertreter http://www.winvistaside.de/
-
Proposed as answer by
Tuesday, August 17, 2010 12:52 PM
-
Marked as answer by
Leo Huang
Wednesday, August 25, 2010 1:14 AM
-
Proposed as answer by
-
Hi harriet, there is a DOS command you can use to run as administrator in command line:
runas /profile /user:administrator “Driver:folderprogram”
For example, the administrator account is “AAA” and you want to run BBB.exe of C:programs, you should do these following steps:
1 Press Win key & R
2 Input “CMD” in open box and click “OK”
3 Input: runas /profile /user:AAA “C:programsBBB.exe” and press “Enter”
4 Input the password of administrator AAA
5 Press “Enter”
Hope it works.
-
Marked as answer by
Leo Huang
Wednesday, August 25, 2010 1:14 AM
-
Marked as answer by
This works for me on all platforms, including Windows 10. My needs are simple, perhaps you can adapt the approach if you need power.
I came up with a small script named, sudo.cmd
named for the Linux sudo command. It works well enough it think. I’ve outlined the requirements, the steps to follow and the script is near the bottom with an example. First a word of warning.
WARNING:
The command runs in the windows System directory by default. You will want to cd
to somewhere safe first.
requirements:
- Run command with Administrator a privileged from windows .CMD
or the cmd-shell. - require the normal Windows privilege checks on the command
- In other words the command will NOT work unless I am already
logged in with a privileged account.
- In other words the command will NOT work unless I am already
- Execute the command with Admin permission and continue when
called inside a script. So wait for the command to complete. - Be simple so it will always work
- Not need to enter a password every time, if I’m already logged in.
- A better method would be if I can enter password once as does
the realsudo
command on Linux.
- A better method would be if I can enter password once as does
solution:
- Create a command script to execute all the arguments passed,
sudo.cmd
- Create a Windows short-cut to the command script name it:
sudo.lnk
. - Put the
sudo
short-cut in your windows PATH so it can be seen. - Edit the short-cut properties, make the
Start in:
path empty. - Click the [
Advanced
] button — CheckRun as Administrator
- Enable short-cuts in your windows path, use the PATHEXT environment variable, viz.
d:> echo %PATHEXT%
.lnk;.EXE;.CMD;.BAT;.COM
When you type sudo dir
on the command-line Windows will show the
User Account Control
Do you want to allow this app to make changes to this device?
[YES] [NO]
Access control pop-up. If you click «[NO
]» nothing will happen. Windows will show an «Access is denied.
» message.
When you click «[YES
]» then the directory command runs at an elevated privilege. Of course you probably want something more interesting like stopping or query on a service:
sudo sc query SDRSVC
SDRSVC is the service name for «Windows Backup service», this shows the following in a separate Cmd window:
[sudo]
administrator
---------------
sc query SDRSVC
SERVICE_NAME: SDRSVC
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
[done]
Press any key to continue . . .
The sudo.cmd
script itself is very basic. As I said my needs are simple. I just want to stop and start services while I deploy code for testing.
sudo.cmd
:
@echo off
@rem sudo.cmd
cd /d %temp%
@echo.
@echo. administrator
@echo. ---------------
cd
@echo.
@rem _________________________________________________
@rem -- Print usage . . .
@if [""] ==["%~1"] goto USAGE
@if /i ["--HELP"]==["%~1"] goto USAGE
@rem _________________________________________________
@rem
@echo. %*
@rem
%*
@rem
set EXIT_STATUS=%ERRORLEVEL%
@rem -- -- -- -- --
@echo.
@echo. [done]
@rem ______________________________________________________
:Exit
@echo.
@pause
exit /b %EXIT_STATUS%
@rem ______________________________________________________
:USAGE
@echo.
@echo ^Usage:
@echo. sudo ^<complete command line^>
@echo.
@echo. Attempts to rune the: ^<complete command line^>
@echo. under Administrator priviliges. Relies on Windows
@echo. prompt for elevated privileges.
@rem ______________________________________________________
@goto Exit
The pause
command waits for you to review the results. If you take pause
out the administration window closes and you don’t know if the command worked or not. The ERRORLEVEL
from the command is returned as well.
(Image credit: Windows Central)
On Windows 10, the ability to run an app as administrator is an essential skill that every user should know because, by design, apps operate in user mode to prevent potential unwanted system changes that may negatively affect the experience. However, sometimes, some trusted programs may require elevated permissions to work as intended, and knowing the steps to run them with appropriate permissions will come in handy.
Whatever your reason it might be, Windows 10 includes several methods to quickly start an app with elevated privileges using the Start menu, File Explorer, Command Prompt, and more.
But remember that this is only true for traditional desktop (Win32) programs since apps available through the Microsoft Store can’t run elevated.
In this Windows 10 guide, we’ll walk you through the different ways to launch an app with administrator privileges to complete an elevated task.
- How to run app as administrator using Stat menu
- How to run app as administrator using Search
- How to run app as administrator using desktop
- How to run app as administrator using Run
- How to run app as administrator using Task Manager
- How to run app as administrator using File Explorer
- How to run app as administrator using Command Prompt
Using the Start menu, you have at least two quick ways to start an application as an administrator.
To run a program as administrator from the Start menu context menu, use these steps:
- Open Start.
- Right-click the app (anywhere on the menu).
- Select the More submenu, and click the Run as administrator option.
To start an app with admin right using the keyboard shortcut, use these steps:
- Open Start.
- Use the Ctrl + Shift keyboard, and click the app from the list.
- (Optional) Select app using the arrows keys.
- Use the Ctrl + Shift + Enter keyboard shortcut.
How to run app as administrator using Search
If you use the search experience, you also have two ways to run apps with administrative permissions.
To open an app as an administrator from the search box, use these steps:
- Open Start.Quick tip: You can also open search directly from the taskbar (if available), or use the Windows key + S keyboard shortcut.
- Search for the app.
- Click the Run as administrator option from the right side. (Sometimes, the option is hidden until you click the down-arrow button.)
- (Optional) Right-click the app and select the Run as administrator option.
Search keyboard shortcut
To run a program from search with a keyboard shortcut, use these steps:
- Open Start.
- Search for the app.
- Use the Ctrl + Shift + Enter keyboard shortcut.
How to run app as administrator using desktop
On Windows 10, you can also start apps elevated from the desktop or taskbar.
To start an app with elevated privileges from the desktop, use these steps:
- Use the Windows key + D keyboard shortcut to view the desktop.
- Right-click app, and select the Run as administrator option.
To run apps elevated from the taskbar, use these steps:
- Right-click the app in the taskbar.
- Right-click the app name.
- Select the Run as administrator option.
How to run app as administrator using Run
To start a program as an admin user from the Run command, use these steps:
- Open Start.
- Search for Run and click the top result to open the app.Quick tip: You can also open the Run command using the Windows key + R keyboard shortcut.
- Type the name of the app. For example, explorer.exe.
- Use the Ctrl + Shift keyboard shortcut and click the OK button.
How to run app as administrator using Task Manager
To launch an app as an administrator from Task Manager, use these steps:
- Open Start.
- Search for Task Manager and click the top result to open the app.Quick tip: Other alternative ways to open the experience include, right-clicking the taskbar and selecting the Task Manager option. Using the Ctrl + Shift + Esc keyboard shortcut, and using the Ctrl + Alt + Delete shortcut and clicking the Task Manager option.
- Click the File menu
- Select the Run new task option.
- Type the name of the app.
- Check the Create this task with administrator privileges.
How to run app as administrator using File Explorer
File Explorer includes at least two ways to launch apps as an administrator user.
To open app elevated with File Explorer, use these steps:
- Open File Explorer.
- Navigate to the folder with the executable file.
- Right-click the app and select the Run as administrator option.
To run a program as an administrator with the ribbon menu, use these steps:
- Open File Explorer.
- Navigate to the folder with the executable file.
- Select the app.
- Click the Application Tools tab.
- Click the Run as administrator button.Quick note: If you click the arrow button, then you can select to launch the app as admin or as a different user.
How to run app as administrator using Command Prompt
To run an app elevated from Command Prompt, use these steps:
- Open Start.
- Search for Command Prompt and click the top result to open the console.
- Type the following command to run an app with administrator privileges and press Enter:`runas /user:»COMPUTER-NAMEADMIN-USER» «C:PATHTOPROGRAM.EXE»In the command, make sure to update the syntax with your computer name and administrator user and with the correct path of the program.For example, this command start PowerShell 7 with administrator privileges:
runas /user:"office-pcuser@email.com" "C:Program FilesPowerShell7pwsh.exe"
- Confirm the password and press Enter.
If you want to run an app always as an administrator, you can use these steps.
Get the best of Windows Central in in your inbox, every day!
Mauro Huculak is technical writer for WindowsCentral.com. His primary focus is to write comprehensive how-tos to help users get the most out of Windows 10 and its many related technologies. He has an IT background with professional certifications from Microsoft, Cisco, and CompTIA, and he’s a recognized member of the Microsoft MVP community.