How to force a WPF application to run in Administrator mode
You need to add an app.manifest
. Change the requestedExecutionLevel
from asInvoker
to requireAdministrator
. You can create a new manifest by using the add file dialog, change it to require administrator. Make sure that your project settings are set to use that manifest as well. This will allow you to simply double click the application and it will automatically prompt for elevation if it isn't already.
See here for more documentation:
http://msdn.microsoft.com/en-us/library/bb756929.aspx
EDIT:
For what it's worth, the article uses VS 2005 and using mt.exe
to embed the manifest. if you are using Visual studio 2008+, this is built in. Simply open the properties of your Project, and on the "Application" tab you can select the manifest.
- Right-click your WPF project to add new Item: "Add->New Item..."
- Select "Application Manifest File" and click Add
- Double Click your newly created manifest file and change the
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
to
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Then the WPF application would run as Administrator.