3

Hi when i try to open my app in win-xp it works fine but when i try it on win7 it says access to path (path location) is denied unless i open it as administrator so how can i give my app administrator rights without promoting

Thank you

shandoosheri
  • 492
  • 1
  • 6
  • 16
  • possible duplicate of [How to force C# App to run as administrator on Windows 7](http://stackoverflow.com/questions/2818179/how-to-force-c-app-to-run-as-administrator-on-windows-7) – Hans Passant Aug 31 '11 at 22:00

1 Answers1

8

You can't gain administrator rights on a system with UAC without passing through UAC elevation.

Your options are:

  1. Manifest your app so that it always runs as administrator. The user sees the UAC dialog every time they start the app.
  2. Separate the part of the app that needs admin rights into a separate process and just require elevation for that part.
  3. Re-work your app so that it doesn't need admin rights.

Of these options you should prefer 3. If you can't achieve that then 2 is better than 1.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Thank you David for your answer but option 3 is very hard to accomplish so I guess that option 2 will be best but will it also display the uac window and can you tell me how can I make this in many parts of my application. Thank you – shandoosheri Aug 31 '11 at 22:37
  • Hi 3 is hard bec my app start other files but I will reconsider it. – shandoosheri Aug 31 '11 at 23:19
  • I can't encourage you strongly enough to avoid needing elevation if possible. It is usually possible. – David Heffernan Sep 01 '11 at 06:31