Search code examples
vb.netvisual-studio-2010setup-deployment

Executable not requesting elevated when part of deployment project


I've created an executable that's called by another app for processes that require UAC elevated privileges. If I build this project with the below manifest it requests UAC fine, if I add this projects output to my setup project it creates it without UAC?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
   <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="CreateApp" type="win32"/>
   <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

Any idea why this is or if it's possible to have it as part of the setup project with the manifest?


Solution

  • Custom actions in InstallExecuteSequence already run as child processes of Windows Installer service. So they inherit their privileges and the manifest is not used.

    To run a custom action with full privileges you should schedule it as deferred with no impersonation.

    If you are not using the EXE as a custom action and you are just launching it from another process, make sure you use ShellExecute.