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.

  • RSS
  • email
  • Facebook
  • Twitter
  • Digg
  • del.icio.us
  • Google Bookmarks

7 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:
    c:\batchfiles\mybatch.bat

    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.

    Thanks

  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.
    jon

  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…

Leave a reply