Hi, I've prepared a small script to add into post-build event.
the typical comand line looks like: cscript //B "$(SolutionDir)patchmanifest.js" "$(TargetPath)" "$(ProjectDir)res\description.manifest" "$(ProjectDir)res\indent.xsl"
description.manifest content:
< xml version="1.0" encoding="UTF-8" standalone="yes" >
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<description>YourAppName Application</description>
<!-- Identify the application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
patchmanifest.js content:
XMLVER = "Msxml2.DOMDocument.3.0";
var oArgs = WScript.Arguments
if (oArgs.length < 2)
{
WScript.Echo("Usage: patchmanifest app.exe patch.manifest [stylsheet]");
WScript.Quit(1);
}
try
{
var Shell = WScript.CreateObject("WScript.Shell");
var oExec = Shell.Exec("mt.exe -nologo -out:$tmp.manifest -inputresource:\"" + oArgs(0) + "\"");
while (oExec.Status == 0) { WScript.Sleep(100); }
if (oExec.Exitcode != 0)
{
WScript.Echo("Manifest Tool error");
WScript.Quit(2);
}
var xml = WScript.CreateObject(XMLVER);
xml.async = false;
xml.load("$tmp.manifest");
var pat = WScript.CreateObject(XMLVER);
pat.async = false;
pat.load(oArgs(1));
var node = pat.documentElement;
while (node.hasChildNodes())
{
xml.documentElement.appendChild(node.firstChild);
}
if (oArgs.length > 2)
{
var xsl = WScript.CreateObject(XMLVER);
xsl.async = false;
xsl.load(oArgs(2));
var out = WScript.CreateObject(XMLVER);
out.async = false;
out.validateOnParse = true;
xml.transformNodeToObject(xsl, out);
out.save("$tmp.manifest");
}
else
{
xml.save("$tmp.manifest");
}
Shell.Exec("mt.exe -nologo -manifest $tmp.manifest -outputresource:\"" + oArgs(0) + "\"");
WScript.Quit(0);
}
catch (e)
{
WScript.Echo("ERROR:", e.name, "-", e.description);
}
and another one is patchmanifest.vbs
Const XMLVER = "Msxml2.DOMDocument.3.0"
On Error Resume Next
Set oArgs = WScript.Arguments
if oArgs.Count < 2 then
WScript.Echo "Usage: patchmanifest app.exe patch.manifest [stylsheet]"
WScript.Quit 1
end if
Set Shell = CreateObject("WScript.Shell")
Set oExec = Shell.Exec("mt.exe -nologo -out:$tmp.manifest -inputresource:" & Chr(34) & oArgs(0) & Chr(34))
do while oExec.Status = 0
WScript.Sleep 100
loop
if oExec.Exitcode <> 0 then
WScript.Echo "Manifest Tool error"
WScript.Quit 2
end if
Set xml = CreateObject(XMLVER)
xml.async = false
xml.load "$tmp.manifest"
Set pat = CreateObject(XMLVER)
pat.async = false
pat.load oArgs(1)
Set node = pat.documentElement
do while node.hasChildNodes
xml.documentElement.appendChild(node.firstChild)
loop
if oArgs.Count > 2 then
Set xsl = CreateObject(XMLVER)
xsl.async = false
xsl.load oArgs(2)
Set out = CreateObject(XMLVER)
out.async = false
out.validateOnParse = true
xml.transformNodeToObject xsl, out
out.save "$tmp.manifest"
else
xml.save "$tmp.manifest"
end if
Shell.Exec("mt.exe -nologo -manifest $tmp.manifest -outputresource:" & Chr(34) & oArgs(0) & Chr(34))
WScript.Quit 0
if Err <> 0 then
WScript.Echo ""
WScript.Echo "Error:", Hex(Err.Number), "-", Err.Description
Err.Clear
end if