Search code examples
.netmanifest.net-assemblyaccess-rights

requestedExecutionLevel requireAdministrator doesn't work as expected


I have an app.manifest file as following:

<?xml version="1.0" encoding="utf-8"?>
<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">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
       <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
          <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
       </requestedPrivileges>
    </security>
  </trustInfo>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>      
    </application>
  </compatibility>  
</asmv1:assembly>

I expect that only an administrator will be able to launch the executable, but it doesn't work that way. Pretty much any user is able to launch it. What could be wrong with my app? Where should I look for a mistake?

Thanks in advance.


Solution

  • I suppose, that users, who can launch this application have disabled UAC. It this case it's possible to launch application, but it will fail. Step 6: Create and Embed an Application Manifest (UAC) (table: Application launch behavior for a standard user account)