Installing SAPI with CyberInstaller »
« Remove flickering during resizing and correct controls rendering under Vista

Automatically start a process with administrative rights under Windows Vista

If you have the need to start a process (executable) with administrative rights under Windows Vista, without using the pop-up menu and the "Run as Administrator…" item, so that the user just double click on it, then it’s possible to use a manifest file with the following content:

<?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=”isVista” type=”win32″/>
      <trustInfo xmlns=”urn:schemas-microsoft-com:asm.v2″>
         <security>
               <requestedPrivileges>
                   <requestedExecutionLevel
                       level=”requireAdministrator”/>
               </requestedPrivileges>
         </security>
      </trustInfo>
  </assembly>

This will automatically elevate the executable rights, but the user will be prompted for an administrator password (if he does not belong to the Administrators group).

An already compiled file can be found here. As all manifest files, it must be placed in the same folder of the .exe file and renamed in the following way:

<executable name>.exe.manifest

If you do not want the user to see the manifest file, it is possible to use MT (a Microsoft utility downloadable from here) to embed the manifest inside the executable itself. With this tool you can write the following line from the command prompt. Eg. supposing you have a test.exe file and a test.ext.manifest file you can write:

mt.exe -manifest “test.exe.manifest” -outputresource:”test.exe”

This way you will obtain a test.exe file with the manifest file embedded in it. The user will see the executable file only and he’ll just have to run it to execute the application with administrative rights (a password will be asked, of course).

More information here.

Tuesday, January 29th, 2008 : Software development, Windows : No Comments

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>