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.


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.


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.

13 Responses to “Always Run a Batch File as an Administrator”

  1. ekis says:

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

  2. John says:

    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:

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

  3. JorGe says:

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

  4. Kevin Bailey says:

    Any chance of explaining how a batch file can be made to run with admin privileges by a normal user.

    I know about the security risks etc and am fine with the implications. We need to fix a bug introduced with Vista SP1 and the users need to run a batch file to fix this issue.

    Please email me at the supplied address.


  5. jon says:

    thanks – works a treat. i was trying to sort it out for a while without success – by trying to login as admin from within the batch file.

  6. sneha says:

    how can i login as admin within a batch file. I also want to do. I tried runas command. but it is prompting password. I want to run one batch file from normal user login but i want it to run with administrative privilage. and also i dont want user to know about the password also.

    please help me…

  7. Tariq says:

    Hi Tony,

    I had created a batch file for my mom but was laking Admin rights option (Windows 7) – now everything works fine :)

    Thank You.

  8. Greg says:

    This doesn’t work for me (Vista Pro x64). I did as instructed, tried with cmd /c as well. All I have in my (test) BAT file is ‘pause’ so I’d expect it to pause but it doesn’t. It does when ran as a non-admin but doesn’t neither when right-clicked and Ran as Administrator nor with the shortcut trick.

  9. Thomas says:

    Hey Im running windows 7 trying to get this to work on my computer with a batch file. Only even when I make a shortcut the always run as admin box is greyed out and cant be selected how does one go about correcting this?

  10. Bryan Klumpp says:

    I am having the same problem as Thomas, on Windows 7 x64 Professional. Tried with and without cmd /c

    • Gary says:

      In Windows 7, there is no need to run a batch file to restart the spooler service. Open up ‘Device and Printers’, right click on your default print device and select ‘Troubleshoot’. If it finds a problem with the Spooler service, it will restart it.