Search code examples
c#.netwindowsmanifestelevated-privileges

How reliable is adding an application manifest to ensure elevated privileges across windows xp, vista and 7?


How stable is this method to ensure that my admin application requests admin privileges when launching:

<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>

This works well on Windows 7 but I do not have access to XP and Vista so cannot tell.


Solution

  • By specifying that manifest, you tell Windows (Vista or 7), if a standard user (admin as well with UAC enabled) tries to execute this app, UAC prompt should appear. Without elevation, this app won't work as expected.

    Both Windows Vista and Windows 7 can handle this properly, as that's why UAC is designed.

    For Windows XP, a standard user needs to use runas manually to execute your app as admin, while an admin user can run it directly. There is no UAC on Windows XP, and it falls back to the old behaviors long time Windows developers familiar with.

    To test out Windows XP, you should use Windows XP mode, http://www.microsoft.com/windows/virtual-pc/download.aspx