Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

admin

I have a program that uses the registry to save the last 10 files that have been opened. At one time I was trying to save them in local machine, but instead decided to save them in the current user. During the course of trying to get everything to work I created a manifest to force the program to Run As Administrator, which I don't beleive is required any more. The problem I'm having is I can't seem to remove the requirement.

I have.... Changed the project properties to "Create application without a manifest", Added a new item called app.manifest which defaults to asInvoker and changed the properties to use that manifest, renamed any file that has the word manifest in the file name.

None of these attempts worked. The program still is running as an administrator. I must be missing something but I'm not sure what.

Here are the lines in the app.manifest

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

Thanks for the help!!

Gary

like image 772
Gary Avatar asked Jul 12 '12 17:07

Gary


People also ask

How do I get rid of Run as administrator icon?

a. Right-click on the program's shortcut (or exe file) and choose Properties. b. Switch to the compatibility tab and uncheck the box next to "Run this program as an administrator".

Is run as administrator permanent?

You can run a program once as an administrator, or you can set a program to permanently run as an administrator.


1 Answers

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

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

Add the following line instead of this:

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

If this did not help, first make sure that you also removed the manifest file from the bin\Debug folder. Simply removing it from the solution does not help, because the file might still be available in the output folder.

That's why I think you should not remove the manifest file from the project, but change it that it works as expected.

like image 195
Carsten Schütte Avatar answered Sep 26 '22 00:09

Carsten Schütte