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!
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.Also on: