title: VS2010 Setup Project - Run As Administrator
body: <p>I have a VS2010 solution with 2 projects in it - a .NET 4 program, and an installer for it. The Installer is just a simple Setup Project with a prerequisite - .NET Framework 4.</p>
  
  <p>The problem is that I need the installer <strong>setup.exe</strong> to always run as Administrator otherwise the setup will fail under the UAC. (It does not prompt me for privilege elevation by default.)</p>
  
  <p>I tried putting a <strong>setup.exe.manifest</strong> (shown below) alongside the setup.exe to force it to run as administrator, but unfortunately Windows ignores it, most likely because there is already <em>another</em> manifest file embedded within the setup.exe itself and it's set to <em>asInvoker</em> rather than <em>requireAdministrator</em>.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
    &lt;assemblyIdentity version="1.0.0.0" name="MyApplication.app"/&gt;
    &lt;trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"&gt;
      &lt;security&gt;
        &lt;requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"&gt;
          &lt;requestedExecutionLevel level="requireAdministrator" uiAccess="false" /&gt;
        &lt;/requestedPrivileges&gt;
      &lt;/security&gt;
    &lt;/trustInfo&gt;
  &lt;/asmv1:assembly&gt;
  </code></pre>
  
  <p>I also tried adding a launch condition with the following properties:-</p>
  
  <pre><code>(name): Elevated
  Condition: Privileged
  Message: This installation requires elevated permissions to continue.
  </code></pre>
  
  <p>That doesn't do a thing either.</p>
  
  <p>So can anyone please shed a light on how to solve this issue?</p>
  
  <p>P.S. I know you can workaround this issue by changing the compatibility settings of the setup.exe, but this is a manual process and cannot be done via an automated build process (TFS). Also, providing a shortcut with compatibility setting is also weird, since no one provide a shortcut to a setup.exe in the same folder, not to mention that the shortcut needs to know the exact path of the setup.exe beforehand. (The setup package will be moved around.)</p>
  
  <hr>
  
  <p><strong>Edit:</strong> By the way, my problem is exactly the same as the one described <a href="https://stackoverflow.com/questions/7443930/how-to-make-the-setup-exe-from-a-vs2010-setup-project-ask-for-admin-privileges">here</a>. But unfortunately, no solutions were found for that guy and the asker just resort to ask his clients to use <em>Run As Administrator</em> manually, which is what I'm trying to avoid.</p>