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.
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
This will drive you batty - got to the bottom of it and posted an article and some utilities to help with your manifest being ignored: Find Out Why Your External Manifest Is Being Ignored.
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.
来源:https://stackoverflow.com/questions/1444300/uac-manifest-file-is-ignored