How to transfer application administrator rights in C #? manifest file

I am having problems with my C # application that uses win32_networkingadapterconfig. The problem is that I cannot use the changing functions in win32_networkingadapterconfig when I use the application for a user who does not have administrator rights. I tried to "run as administrator" but no luck. And I tried to create a manifest file with this content in the trustInfo part:

<security> <applicationRequestMinimum> <PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" /> <defaultAssemblyRequest permissionSetReference="Custom" /> </applicationRequestMinimum> <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> </requestedPrivileges> </security> 

Enable click security settings configured to full trust. What am I doing wrong?

0
source share
2 answers

In your fragment hangs "trustinfo". Do it like this:

 <?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="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"> <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> </requestedPrivileges> </security> </trustInfo> </asmv1:assembly> 
+4
source

There are a number of possible problems that I listed in the order in which I suspect, most likely less likely.

Possible problem 1
What are your UAC settings? As described in Create and paste an application manifest (UAC) , if you have disabled UAC and you are requesting administrator permissions

The application may start, but will later

Possible problem 2
There may be something wrong where in the manifest, how is the collection of information required. Holding your entire manifest will help.

Possible problem 3
You have added applicationRequestMinimum node, which is not required for UAC escalation. Maybe you should refuse and try again.

+2
source

Source: https://habr.com/ru/post/920356/


All Articles