Author Topic: Windows: How to force admin-rights?  (Read 2698 times)

Offline jmb

  • Multiple posting newcomer
  • *
  • Posts: 24
Windows: How to force admin-rights?
« on: January 20, 2015, 12:15:48 pm »
Hi

I want that my program brings up the administrator-dialog to get admin-permissions.

In VisualStudio-Express there is a special Linker-switch. But in codeblocks it seems, I
have to use an manifest instead.

This is what I did:

1.) I created an textfile with this content:

Code
Executable: DNS_Umschalter.exe
Manifest:DNS_Umschalter.exe.manifest
Sample application manifest file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity version="1.0.0.0"
     processorArchitecture="X86"
     name="DNS_Umschalter"
     type="win32"/>
  <description>DNS umstellen mit ein paar Mausklicks</description>
  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"/>
        </requestedPrivileges>
       </security>
  </trustInfo>
</assembly>



2.) Then in the rc-File I added this:

#define MANIFEST_RESOURCE_ID 1234
MANIFEST_RESOURCE_ID RT_MANIFEST "DNS_Umschalter.exe.manifest"


After the buildingprocess the executable contents that manifest. All looks ok.

But it doesn't work. The program starts without administrator-dialog.


And Idea ?

Linux Mint, Cinnamon 19.3 , Code::Blocks 20.03