Saturday, 27 April 2013

Force application to run with elevated permissions. Run as Administrator (UAC)

I've been working for a bit on a application that hosts its own wcf service, too long to explain here, but the interesting point is that in order for the web service to be locally hosted, I need to run the app using elevated permissions, which is done very easily by adding a manifest file to the application.

This is the manifest file that you need:

<?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="">
  <assemblyIdentity version="" name=""/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">

You can add this file from Visual Studio and just customize to the required permission level.

No comments:

Post a Comment