Tuesday, October 25, 2011

Run the application in admin mode

You'll want to modify the manifest that gets embedded in the program. Works on VS2008 + 2010: Project + Add New Item, select "Application Manifest File". Change the element to:

Adding a requestedExecutionLevel element to your manifest is only half the battle, you have to remember that UAC can be turned off, if it is, you have to perform the check the old school way and put up a error dialog if the user is not admin (Call IsInRole(WindowsBuiltInRole.Administrator) on your threads CurrentPrincipal)

http://msdn.microsoft.com/en-us/library/bb756948.aspx