How make Executable Dlang EXE ask for "Run as Administrator"?

Ferhat Kurtulmuş aferust at gmail.com
Mon Feb 3 13:13:30 UTC 2020


On Monday, 3 February 2020 at 12:27:41 UTC, Marcone wrote:
> On Saturday, 1 February 2020 at 08:14:19 UTC, Ferhat Kurtulmuş 
> wrote:
>> On Saturday, 1 February 2020 at 06:26:04 UTC, Marcone wrote:
>>> [...]
>>
>> Disclaimer: did not tried. You must somehow embed this 
>> manifest file into your exe using  some linker parameter. Or 
>> put this manifest next to your exe by naming it 
>> MyApplication.exe.manifest.
>>
>> <?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="MyApplication"
>>      type="win32"/>
>>   <description>Description of your application</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>
>
> Work very well when I put this manifest next to your exe by 
> naming it MyApplication.exe.manifest. But how embed this 
> manifest file into exe using linker parameter? Can you send me 
> the exemple command?

A quick google search shows many ways:

1) 
https://stackoverflow.com/questions/44030618/embedding-manifest-to-exe-file/44031483
this one would have worked if we had a working GDC compiler on 
windows. Just skip to another option:

2) 
https://docs.microsoft.com/en-us/cpp/build/how-to-embed-a-manifest-inside-a-c-cpp-application?view=vs-2019

mt.exe -manifest MyApp.exe.manifest -outputresource:MyApp.exe;1

PS: mt.exe is available with my cmd because Windows Kits are 
installed on my Windows computer. I don't know how to have it 
working otherwise.

3) 
https://docs.microsoft.com/en-us/cpp/build/reference/manifest-create-side-by-side-assembly-manifest?view=vs-2019

This requires you to use visual studio. Maybe it can be achieved 
with VisualD, I don't know.


More information about the Digitalmars-d-learn mailing list