How to Run a Batch File as Admin in Windows 7

This is quite a handy tip I picked up this week when I had a Windows batch file which I needed to run with administrator privileges.

Of course, you can find the file, right click it, select Run as Administrator and do it that way, but if you need to run this file more than a few times, that soon gets to be a pain in the neck.

So, the way to have this file run with elevated privileges every time is as follows:

  1. Open Windows Explorer (Windows key + E) and locate the file in question.
  2. Right click the file and select Create Shortcut.
  3. Rename the shortcut to something sensible.
  4. Right click on the shortcut and select Properties.

    Win 7 dialogue box displaying shortcut properties"

  5. In the window that now appears, make sure that the Shortcut tab is selected.
  6. Click on the Advanced button.
  7. Put a tick in the box that says Run as Administrator
  8. Click OK twice.

    Win 7 Run as Admin Dialogue"

Now, when you double-click the batch file, UAC will prompt you for administrative privileges.

You can also use this technique to always run the command prompt, or any other application for that matter, as administrator.

Extra tip: in Windows 7 you can start any program that you have pinned to the toolbar with administrator privileges, simply by holding Ctrl + Shift when you click on it.