Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to distribute a program to windows (XP, 7, 8) users. The program requires administrative rights because it adds and removes routes, among other things. The problem is that the "Run this program as administrator" flag on the executable is not preserved, so I figure I could programmatically add this using a batch script or something similar in a sort of setup script.

Is this the right approach, and if so how does one add this flag?

share|improve this question
AFAIR you have to embed a manifest file in your executable. – gronostaj Aug 5 '13 at 9:33
So if such a manifest file specifically states that the executable should carry this flag/option, it will be inherited when I copy the executable to another system? – user135361 Aug 5 '13 at 9:55
@gronostaj: Embedding is allowed, but not necessary. You can also have it in a side file (app.exe.manifest). But yes, this is a major pain. A sane OS designer would have added this flag where all the other similar flags are (in the PE header), but not Microsoft. – MSalters Aug 5 '13 at 10:02
@user135361 Yes. See my answer below for an example. – gronostaj Aug 5 '13 at 10:03
up vote 7 down vote accepted

You can include a manifest file in executable's resources. It will make Windows require Administrator privileges for that file on all systems.

You can open any installer with Resource Hacker and you'll find an XML file like this one:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft-com:asm.v2">
        <ms_asmv2:requestedExecutionLevel level="requireAdministrator" uiAccess="false"></ms_asmv2:requestedExecutionLevel>

That's the manifest file. You need something like this compiled into resources.

share|improve this answer

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.