Force your .NET application to ask for elevation

If you don't run the application in an elevated mode in windows Vista and above, you may encounter some access denials from time to time. 

To avoid these incidents and the need to right click and run as administrator - all you have to do is to create a custom manifest that will contain a similar XML to the one below:


<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="UacDemo" type="win32"/>
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
      <security>
         <requestedPrivileges>
            <requestedExecutionLevel level="requireAdministrator"/>
          <requestedPrivileges>
       <security>
    <trustInfo>
<assembly>

Post a Comment

Previous Post Next Post