Click here to Skip to main content
14,303,166 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello,

How do I launch my application at startup which required elevation. Currently I use standard method by using registry. But somehow it doesn't work, it seems ignore, no application started. Anyone have an idea>
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 2

You need to create a manifest file for your application.

place the manifest file within your application that may contain :

<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="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <!-- UAC Manifest Options
            If you want to change the Windows User Account Control level replace the
            requestedExecutionLevel node with one of the following.
        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />
            If you want to utilize File and Registry Virtualization for backward
            compatibility then delete the requestedExecutionLevel node.
        -->
        <requestedExecutionLevel level="requireAdministrator" uiAccess="true" />
      </requestedPrivileges>
      <applicationRequestMinimum>
        <defaultAssemblyRequest permissionSetReference="Custom" />
        <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
      </applicationRequestMinimum>
    </security>
  </trustInfo>
</asmv1:assembly>


When you invoke the application it will run as administrator.
   
Comments
Kunal Chowdhury «IN» 13-Sep-10 7:05am
   
Excellent Answer... :thumbsup:
Pdaus 13-Sep-10 14:36pm
   
Still got popup uac...how do i bypass it?
Rate this:
Please Sign up or sign in to vote.

Solution 1

With Windows 7, your main hurdle will be the fact that Windows 7 automatically blocks startup programs that take longer than they should to startup. Hence the bubble you will often see that says "Windows has blocked some startup programs"

You would have to find some way of giving consent via pre-defined login credentials and UAC API
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100