views:

811

answers:

2

One of my Executables writes some configuration into a XML file to C:\Program Files\MyApp\config.xml. It needs to run as Administrator on Vista / Server 2008, otherwise the OS won't let it write to that location.

I included a manifest file named config.exe.manifest, to automatically request administration rights at launch.

Here's my manifest file:

<?xml version="1.0" encoding="utf-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

I tried this on Windows Server 2008, but the manifest file seems to be ignored and the executable is launched without sufficient rights.

A: 

Ok it works when I embed the manifest file using MT.EXE. Still don't why it doesn't work when I provide the manifest as a separate file, but I guess embeding is a good enough solution.

Jan Gressmann
antony is right: Check that you don't have *any* manifest built into the executable - then Windows' loader will use the external one.
Ian Boyd
+2  A: 

http://blogs.msdn.com/junfeng/archive/2009/05/11/internal-manifest-vs-external-manifest.aspx

quoted from above link: In Windows XP, Sxs searches external manifest before internal manifest. If an external manifest is found, the internal manifest is ignored.

In Windows Server 2003 and later, the order is reversed. Internal manifest is preferred over external manifest.

If you use external manifest, and your scenario works in Windows XP, but not Windows Server 2003 and later, please double check the executable does not have an internal manifest

antony

related questions