Its been an exciting day here at the Wildermuth compound. I noticed that the old setup for my SQL Server Monitor project was broken (mostly dependencies were wrong), so I figured I’d just open it up and tweak a couple of settings and move along with my day. D’oh!
Seems that I’d lost the source to that project. I use Subversion to save my sources locally but that project pre-dated that source control. What to do? Well, I rebuilt it using Reflector to give me the old code. Then I rebuild the setup using Visual Studio 2008’s Setup projects (which suspiciously don’t seem like they’ve changed since their inception in Visual Studio 2002!).
Since I had to rebuild the source, I thought it was time to fix the one nagging ‘bug’ in the code. Not really a bug since it was built without UAC in mind, it required it be to run as Admin on UAC enabled machines (since it mucks with the services and such). I thought I was going to have to dig into some arcane Win32 stuff to get it to work, but interestingly all it needed was a manifest file:
<?xml version="1.0" encoding="utf-8"?> <asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <assemblyIdentity version="126.96.36.199" name="MyApplication.app"/> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> <!--<requestedExecutionLevel level="asInvoker" uiAccess="false" />--> </requestedPrivileges> </security> </trustInfo> </asmv1:assembly>
The trick was adding the **‘requireAdminstrator’ **as a requestedExecutionLevel. Once the manifest was added as an embedded resource, Vista/2008 recognizes it needs some admin privledges and should ask the user when necessary.
Go get the new setup file if you want to be my beta tester! Please email me at shawn (at) wildermuth.com if you find any bugs.