Wednesday, November 15, 2006

Windows Vista Manifest File Issues

In the process of upgrading a product to work with Windows Vista and having way to much fun.

Part of my issues have been with adding the new requestedExecutionLevel to an exe so it can be run as an administrator.

Per Microsoft Vista Documentation a manifest needs to be added which adds the appropriate requestedExecutionLevel, in my case administrator.

So how do you add the requestedExecutionlevel to a program?

1) Create a file and paste the required XML found in the Microsoft Vista Documentation

It looks something like this:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestversion="1.0">
<trustinfo xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedexecutionlevel level="requireAdministrator" uiaccess="false">

2) Tell VC8 about the manifest file you just created. From the VC8 project properties you need to go to Manifest Tool > Input and Output > Additional Manifest Files. Set Additional Manifest Files to be the filename you created above.

3) Compile your project.

If you have a working Manifest Tool program, your program will now have a good manifest file. If you don't, then the manifest created will be broken, and your program will have a great feature when run on Windows XP. It will automatically reboot the computer for you!! Isn't that wonderful?

The fix for this Windows Vista Manifest crash on Windows XP is a gem I found in one of the Microsoft Forumns. Since it is a gem, the solution is buried away in the forumn. Here is the gem:

In Windows Visual Studio 2005 there are multiple copies of the mt.exe (Manifest Tool) program. There is an older version in the $InstallDir\VC\bin that you need to replace with the mt.exe found in $InstallDir\Common7\Tools\Bin.

Follow the above steps and you should have a program that will run as an administrator on Windows Vista and actually work on previous versions of Windows without crashing. (Always a plus)

Possible additional steps, use your code signing certificate and sign the executable for a more user friendly dialog when your program is run on Windows Vista.

No comments: