Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am wondering whether it is possible to automatically open a batch file as admin when you double click on the batch file, because the commands need to be run with administrative rights.

Note: I already know about solution that require right clicking on the file and clicking on Run As Administrator, but this is not automatical solution.

share|improve this question

3 Answers 3

up vote 7 down vote accepted

Yes, you're able to run a batch file with administrative rights. Unfortunately, you can't do this directly from the batch file it self. You would need to first create a shortcut of that batch file and change the properties for that shortcut in order to make this work.

To create a shortcut, there are many ways but the simplest and the fastest way is by using the Send to option in the context menu.

Right click batch file > Send to > Desktop (create shortcut)

Of course you can send the shortcut to where ever you would like. To elevate the batch file to run as admin, follow the steps below:

  1. Right-click the shortcut you just created (should be on the desktop or where ever you send it)
  2. Under the Shortcut tab, click the Advanced... button.
  3. Check the Run as administrator checkbox and press OK to both the modal window and the main properties window.
  4. Run the shortcut by double-clicking it and the batch file should run as administrator.
share|improve this answer
Thanks this really helped alot! –  Antp Jul 28 at 4:50
You could always force the batch file to call the shortcut, and have the shortcut pass a parameter to know not to call the short cut. You would insert something like if "%~1" == "" start %USERPROFILE%\Desktop\Shortcut.lnk && GOTO :EOF right below @echo off, and make the shortcut link to program.bat a instead of just program.bat. –  trlkly Jul 28 at 5:20

Alternatively you could create a second batch file, this could allow you to run anything as an administrator, while only entering the administrator password once. The password is saved in an authentication token, and takes some real computer know how to crack.

runas /savecred /user:(domain)\(admin user) "(file path to exe,bat,whatever)"
share|improve this answer

You can run batch files as admin by right clicking on the file and clicking on Run As Administrator

Alternatively, you could also do Shift+Right Click then click on Run as Different User if you need to run it as a user with administrative privileges.

share|improve this answer
Sorry this is useless because i want it to run as admin automatically. –  Antp Jul 28 at 4:52
Right. Misread the question. –  Lawrence Jul 28 at 4:53
Thats alright mate. –  Antp Jul 28 at 5:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.