AutoHotkey and Run As Administrator

For as long as I've been developing ColdFusion (and now Railo) I've always had a few batch files to start/stop and restart my web services:

My restart script for example will shutdown my SQL and web server (in this case MSSQL and IIS) and Railo and restart them all.

net stop "W3SVC"
net stop "MSSQLSERVER"
net stop "RAILO"

net start "W3SVC"
net start "MSSQLSERVER"
net start "RAILO"

I have a simple AutoHotkey script that will run this with a single keypress:

Note: I'm using a Microsoft Natural keyboard with several additional function keys and have this mapped to the '=' key on the number pad.

;numpad=
run "C:\scripts\batch\railo_restart.cmd"
return

Unfortunately my laptop is locked down and I need to "Run as administrator" which requires me to

Yikes!

Turns out the solution was fairly simple...

(I'm using Windows 7 btw)

  1. Create a shortcut to the script you want to run
  2. Right click the shortcut and hit Properties
  3. On the Shortcut tab click the Advanced button
  4. Check the 'Run as Administrator' option (if this is grayed out curse Microsoft and hit Google for some solutions)
  5. Click OK
  6. Turn off UAC (this is a security risk!). This eliminates the confirmation.

Now tweak the AutoHotkey script to point to the shortcut instead

;numpad=
run "C:\scripts\batch\railo_restart - Shortcut.lnk"
return

Now when I click the '=' key on my keyboard the script fires off with no prompts or confirmations, running as adminstrator!