Possible Duplicate:
Batch file - start program with admin rights

I'm writing a batch script that requires administrator permissions to execute, so to start it I need to right-click and select "Run as Administrator". Is there a way to elevate permissions form within the script instead, like "su" in *nix?

link|improve this question
If batch files could elevate themselves and circumvent UAC, then malware would have a heyday. :) – techie007 Dec 28 '11 at 21:19
@techie007: This is true. But usually when folks say they need to elevate a script, it doesn't mean to circumvent UAC. Batchfiles have no built in method of even invoking a command that requires admin privileges. And the linked duplicate needs to be updated as that no longer works with UAC. – surfasb Dec 28 '11 at 21:37
1  
I was thinking more along the lines of triggering UAC dialog box – Andrey Dec 28 '11 at 21:45
feedback

closed as exact duplicate by techie007, Mehper C. Palavuzlar, haimg, Mokubai, Sathya Dec 29 '11 at 12:57

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

1 Answer

up vote 3 down vote accepted

Using only a batch file? AFAIK, impossible. You'll need to fire off a VBscript or JScript, which can use the Shell.Execute.

You can look at some examples here or donwload the Elevate Powertoys, which are premade VBscripts and batchfiles you can use.

Also included in the Elevate Powertoys are examples on how to self elevate a batfile.

link|improve this answer
feedback

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