How to remove the requirement "Run as administrator" in C #

I have a program that uses the registry to save the last 10 files that have been opened. Once I tried to save them on the local machine, but instead decided to save them with the current user. While trying to get everything to work, I created a manifest to force the Run as administrator program, which I don't believe, takes more. The problem that I am facing is that I cannot remove this requirement.

I have .... Changed the project properties to "Create an application without a manifest", added a new element called app.manifest, which uses asInvoker by default and changed the properties for using this manifest, renamed any file that has a word manifest in file name.

None of these attempts worked. The program still works as an administrator. I have to miss something, but I'm not sure what.

Here are the lines in app.manifest

<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> <requestedExecutionLevel level="asInvoker" uiAccess="false" /> </requestedPrivileges> 

Thanks for the help!

Gary

+6
source share
2 answers

Take a look at the app.manifest file in the Properties folder. Delete the following line:

  <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> 

Add the following line instead:

  <requestedExecutionLevel level="asInvoker" uiAccess="false" /> 

If this does not help, first make sure that you also delete the manifest file from the bin \ Debug folder. Just removing it from the solution will not help, because the file may still be available in the output folder.

This is why I think you should not delete the manifest file from the project, but change it to make it work as expected.

+8
source

Although this question has been around for more than a year, I answer it because it can save one day.

If you configured the application to run as administrator mode and now want to revoke these rights, you need to follow these steps.

Edit

 <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> 

For

 <requestedExecutionLevel level="asInvoker" uiAccess="false" /> 

Right click on your project -> Clean up your solution -> Restore your solution and that’s it.

+2
source

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


All Articles