DEV Community

Thejana Rathnayake
Thejana Rathnayake

Posted on

Make (.bat) files always open with Administrator permissions

Many of you use, or have used (.bat) Batch files, right? Well, if so, you might know that when you open a (.bat) file it opens without administrator permissions. (unless you run it as administrator)
So, I've made this script that will make all you batch files always runas administrator!

How to run the script?

Well, easy! the script is in this GitHub page and all you have to do is download the script. After downloading, the file could be blocked by your antivirus, because the file contains code that involves editing registry values. if a screen called 'Windows Smartscreen protected your PC', click more info and then click run anyway. Make sure to open the file as administrator that says Make batch files run with elevated permissions. Now, when you click that it should give 2 options on the screen;

Selecting the fist option after running the script

  1. Add
  2. Remove

As by now, you might have guessed already, you have to select the 'Add' option, and click 'YES' on the MSGBOX.

That's it! Now you have added the script to your computer! try opening a (.bat) file and it will start in Administrator mode automatically!

Note!

When You run this script, this makes all batch files to be run in administrator mode, instead of normal mode. This could mean that, even a batch script containing malicious code could easily get unwanted permission and probably will wreck your PC. So make sure to Remove the script when you don't use it anymore!

Thanks for Reading ~!

Top comments (0)