8

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

Gary
  • 1,784
  • 4
  • 18
  • 38
  • 1
    Remove the manifest file from the project. You clearly are doing something wrong, not sure what to suggest, given you provided us with very little details. Have you tried simply editing the current one and/or recreating the solution itself? – Security Hound Jul 12 '12 at 17:46
  • how about a code sample.. if you added something you can surely remove it unless you don't understand what it is that you added in the first place in regards to C# code / functionality – MethodMan Jul 12 '12 at 17:47
  • 2
    I'm not sure what code you want a sample of. As I stated in the original question, I have removed the manifest from the project by changing the project settings, or at least that was my intent. – Gary Jul 12 '12 at 17:54
  • Similar question has been asked [here](http://stackoverflow.com/questions/1850768/how-to-give-my-c-sharp-app-administrative-rights-manifest-file), please have a look [msdn](http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/cb8af5c1-8b06-4d14-a1f3-ed0203354e0c) and [msdn forum](http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/cb8af5c1-8b06-4d14-a1f3-ed0203354e0c) too – Erhan A Jul 12 '12 at 21:00
  • The question you reference and mine are not the same – Gary Jul 13 '12 at 20:29

2 Answers2

12

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.

Carsten Schütte
  • 4,408
  • 1
  • 20
  • 24
  • Thanks for the response! There isn't a manifest file in the Debug directory. I changed the project properties to use app.mainfest (I updated the original question to include the relevant lines) and rebuilt the project and it still runs as an administrator – Gary Jul 12 '12 at 18:21
  • 2
    As I continued forward in my coding and after doing what you suggested I no longer have the problem. I have compiled the program a few times since adding the app.maifest. The frist few times I looked to see if the requirement was still there and it was. I don't know when it changed, but thanks!! – Gary Jul 13 '12 at 21:10
4

Although this question is more than an year old now, but i am answering it as it might save one's day.

If you had configured your application to run as administrator mode and now you want to revoke those rights then you need to perform the following steps.

Change

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

To

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

Right click on your project-->Clean your solution-->Rebuild your solution and that is it.

Ehsan
  • 31,833
  • 6
  • 56
  • 65
  • 1
    WHere do you change that from ? My Setup project has no App.config neither the possibility to add one. I see this 'answer' everywhere but there's no explanation how to create that app.config/manifest. – ExtremeSwat Aug 05 '15 at 12:46
  • Why can't you add one? What sort of project are you working? Is it a win forms application? – Ehsan Aug 07 '15 at 00:12