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:
- Open Windows Explorer (Windows key + E) and locate the file in question.
- Right click the file and select Create Shortcut.
- Rename the shortcut to something sensible.
-
Right click on the shortcut and select Properties.
- In the window that now appears, make sure that the Shortcut tab is selected.
- Click on the Advanced button.
- Put a tick in the box that says Run as Administrator
-
Click OK twice.
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.