Introduction
I write quite a few batch files and some of them need to run as an administrator. This is usually because the elevated permissions are required to access files and folders.
The usual way of doing this is to right click on the batch file in the File Explorer and choose "Run as administrator" from the menu that appears.
Run as administrator, right click menu
Then you get the User Account Control (UAC) popup you have to agree to, to run the script.
User Account Control (UAC) popup
The UAC is an important safety feature of Windows and should not be configured to lessen the protection it gives.
I wondered if there was a way to automate the process, and this page was written.
Alter Shortcut Properties
This method runs the batch file as an administrator but does not remove the UAC popup.
Right click on the .bat file, and choose "Create shortcut" from the menu.
Drag the shortcut to the desktop and rename it to whatever you like.
Right click on the shortcut and choose "Properties" from the menu.
On the "Shortcut" tab of the menu click on "Advanced"
Check the "Run as administrator" box that appears
Use Task Scheduler
This method runs the batch file as an administrator and removes the UAC popup. The batch file has to be run on a schedule or by opening the Task Scheduler and running it from there.
Open Task Scheduler and choose "Create Task..." from the right hand menu.
The important parts of the tabs that open are on the "General" tab, ensure that the "Run with highest privileges" checkbox is checked. The "Triggers" tab can be ignored unless you want to the batch file to be run on a schedule. In the "Actions" tab, choose "Start a program" and the location of the batch file. In the "Settings" tab, ensure the "Allow task to be run on demand" checkbox is checked.
Windows Task Scheduler
Other Solutions
The page Is it possible to automatically run a batch file as administrator on Super User and the links on it has all sorts of interesting solutions to this problem. I tried them all and although most do run the command prompt as an administrator, none override the UAC settings which always shows.
Sources and Resources
Is it possible to automatically run a batch file as administrator (Super User)




