3

I am writing a program in c# that requires it to be run as administrator only when certain actions are taken.

When the user clicks a button it checks if the application is running as an administrator and if it is not than it restarts the application as an administrator.

I don't want it to require admin access all the time since most of the application can be used without it.

The problem I am having is when I try to debug the application in VS2013 and click a button that requires admin access it restarts the program and Visual Studio stops debugging it.

Is there a setting or a debug configuration that will allow VS to always start debugging as administrator?

Tony Brix
  • 4,085
  • 7
  • 41
  • 53
  • do you mean that you always want to run the program as administrator when debugging from visual studio? If so, just run Visual Studio as administrator – default Nov 24 '14 at 17:05
  • Have you tried opening visual studio'run as administrator'??? – Ashwath Nov 24 '14 at 17:06
  • See [this](http://stackoverflow.com/q/20404231/238902) for reference – default Nov 24 '14 at 17:07
  • You can also call [Debugger.Launch](http://msdn.microsoft.com/en-us/library/system.diagnostics.debugger.launch%28v=vs.110%29.aspx) (for instance in your Debug configuration) to attach a debugger to the program. However, I'm not 100% sure what your intentions are with your question.. – default Nov 24 '14 at 17:09

1 Answers1

3

Try this solution apply setting for shortcut (away run with administrator)

right click icon visual studio -> properties -> (Tab) Compatibility -> (Group) Setting -> (check) Run this program as an administrator -> Apply -> OK.

HoangHieu
  • 2,802
  • 3
  • 28
  • 44