How To Run A Batch File As Administrator In Windows 7

There’s a couple of automated command line routines that I’ve needed to write and have run at startup on the VCR, but they require elevation to actually run (damn you, UAC!). My goal has always been to have the machine boot with no input from me until it’s ready, so I needed a way to run these scripts automagically without requiring a physical “right-click, run as administrator” routine before the boot process is finished. To solve this, I needed to figure out how to run a batch file as administrator.

One does not simply right-click and run a *.bat file as administrator, though. Oh, no! Windows doesn’t like that! It takes a little more stupidity to run a batch file as administrator in Windows 7!

One does not simply run a batch file as administrator

Once your batch file is written properly, you’ll need to create a shortcut to the *.bat. This is the first step in the roundabout process. Windows allows shortcuts to *.bat files to be automatically run with elevated privileges while the files themselves cannot (it must be some kind of idiot-proofing to prevent you from running a coup de grace downloaded from the interwebs). Take note, though, that you can’t click the option for “Run As Administrator” from the compatibility tab like you normally would; you must open the “Shortcut” tab, then click the “Advanced” button, THEN select the option to run as administrator.

Once you’ve set the shortcut’s settings to run as administrator, then you can point Task Scheduler or EventGhost at the shortcut and have it run whenever you like!

2 thoughts on “How To Run A Batch File As Administrator In Windows 7”

  1. “Krojamsoft BatchRename” Tool is a powerful tool, that allows you to quickly rename all the files in a specified directory. You can remove spaces, replace spaces with underscore, uppercase/lowercase filename, add a prefix/suffix, remove/replace strings and also catalog files by adding an incremental number to the file name.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.