Categories

Vista Clues provides Windows Vista help, tips, downloads, and news. If you have a question or tip for Tony, send me an e-mail at qa@vistaclues.com

Site search

Main menu:

Archive

Always Run a Batch File as an Administrator

You can run a command prompt or any application as an administrator by right-clicking it and then clicking Run As Administrator. If you have a batch file that you need to always run as an administrator, follow these steps so it runs with the proper privileges every time:

1. In Explorer, right-click the batch file and then click Create Shortcut.

click-create-shortcut.png

2. Rename the new shortcut to something useful, such as “filename-admin rights.bat”.

3. Right-click the new shortcut, and then click Properties.
2. On the Shortcut tab, click the Advanced button.

3. Select the Run as administrator checkbox.

click-run-as.png

4. Click OK twice.

Now, when you double-click the batch file, UAC will prompt you for administrative privileges. You can use a similar technique to always run the command prompt as administrator, or to always run an application as administrator.

For more information, read the Windows Vista Resource Kit (co-authored by your very own Tony Northrup). Got a question for Tony? Send an e-mail to qa@vistaclues.com.

del.icio.us:Always Run a Batch File as an Administrator digg:Always Run a Batch File as an Administrator spurl:Always Run a Batch File as an Administrator furl:Always Run a Batch File as an Administrator fark:Always Run a Batch File as an Administrator blogmarks:Always Run a Batch File as an Administrator Y!:Always Run a Batch File as an Administrator magnolia:Always Run a Batch File as an Administrator

Comments

Comment from ekis
Time: March 23, 2007, 4:39 pm

can u explain me this article for microsoft windows xp???????

Pingback from Reader Question: Running an old FoxPro exe file in vista that is invoked with a Batch file to allow printing on a USB port printer - Windows Vista help
Time: April 9, 2007, 2:35 pm

[...] You can configure a batch file to always run as an administrator (after a UAC prompt, of course) by creating a shortcut to it and then configuring that shortcut to run as an administrator, as I described in the article “Always Run A Batch File As An Administrator”. [...]

Comment from John
Time: April 23, 2007, 6:41 am

In addition to the above steps sometimes a batch file shortcut’s target will need to have cmd /c inserted before the batch file location.

For example a batch for with a target of:
c:\batchfiles\mybatch.bat

would need to be changed to:
cmd /c c:\batchfiles\mybatch.bat

Comment from JorGe
Time: November 12, 2007, 5:43 pm

I did it like you said but when the computer starts the windows defender blocked the .bat file, how can a resolve it?

Write a comment