How to add a manifest to a legacy application (which you cannot or will not recompile)
I used mt.exe from Windows SDK
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe"
to add a manifest to an existing legacy exe to make it Run As Administrator (with elevated privileges) on UAC enabled systems (Vista, Win7 , Win 2008 ...). Here's how:
1)Got a legacy exe file named KSDiag.exe
2)In the same folder create a text file named KSDiag.exe.manifest
3)Put the following lines into the text file:
[?xml version="1.0" encoding="UTF-8" standalone="yes"?]
[assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"]
[trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"]
[security]
[requestedPrivileges]
[requestedExecutionLevel
level="requireAdministrator"
uiAccess="False"/]
[/requestedPrivileges]
[/security]
[/trustInfo]
[/assembly]
Replacing [ with LessThan and ] with GreaterThan
4) Run command:
mt.exe /manifest KSDiag.exe.manifest /outputresource:KSDiag.exe;1
(1 for an EXE, 2 for a DLL
mt.exe –manifest MyApp.exe.manifest -outputresource:MyApp.exe;1
or
mt.exe –manifest MyLibrary.dll.manifest -outputresource:MyLibrary.dll;2
See also: http://msdn.microsoft.com/en-us/library/ms235591.aspx
http://msdn.microsoft.com/en-us/library/aa375649(VS.85).aspx )
Now KSDiag.exe has the manifest added to its resource section. On a UAC enabled OS it gets the shield icon and you get the administrator prompt when you try to run it.
Of course if the file was signed to start with you'll have to resign it.
Yours truly
Klaus Bjorn Jensen
PS (Resource Tuner http://www.restuner.com can do loads of nice stuff.)
2 comments:
mt.exe looks like a tool which comes with .net or visual studio what if i want to install my vb6 app on user machine which has neither?
Hi Hassan
Sorry for the late response.
With the method I described above you’re simply editing the resource section of your executable file. Once that is done you can redistribute it as you normally would – no extra requirements to the target environment. Of course you’ll need mt.exe on your build machine – it comes with Windows SDK usually included with visual studio. Regards Klaus Bjorn Jensen
Post a Comment