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.

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?

share|improve this question

marked as duplicate by Ƭᴇcʜιᴇ007, Mehper C. Palavuzlar, haimg, Mokubai, Sathya Dec 29 '11 at 12:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
If batch files could elevate themselves and circumvent UAC, then malware would have a heyday. :) –  Ƭᴇcʜιᴇ007 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

1 Answer 1

up vote 4 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.

share|improve this answer

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