Wednesday, May 26, 2010

Start Application With Administrative Rights on Windows Vista / 7

In the Windows versions Vista and 7 the User Account Control (UAC) determines, that the currently logged in user, even if he is administrator, is not treated as such. Therefor, when trying to perform actions which might affect the operating system, the probably well known dialog asking for administrative permissions is shown. For us this means, that applications, even when run by the administrator, do not run as administrator and cannot perform actions which require higher permissions.
To equip a program with these higher permissions, we add in the .Net development environment an application manifest (Project - Add New Element - Application Manifest) The content should look somewhat like follows:



We are interested in the line < requestedExecutionLevel level="asInvoker" uiaccess="false">. For requestedExecutionLevel we can chose asInvoker, highestAvailable or requireAdministrator eingetragen werden.
When selecting requireAdministrator, we see at program start the known dialog asking for administrative permissions, after answering with yes, the application is equipped with these rights.

To equip the application without such an application manifest, see this post.

No comments:

Post a Comment