views:

315

answers:

2

How to diable UAC using Visual Studio 2010 to run the compiled app without problems and witout using virtualization?

I mean run the app as administrator. (with shield icon)

+1  A: 

I don't think you can do this programatically on a per use basis. You must either disable it completley in windows or to upgrade your program work under UAC.

Preet Sangha
Yeah i know. With vb 2005 i can do that adding the mainfest, also in vb 2008, but i do the same in 2010 and the mainfes isn't added to executable.
Sein Kraft
+3  A: 

You need to add an application manifest to your application to indicate to the operating system that it requires administrator privileges. This will cause your application to prompt for UAC elevation every time it's launched (regardless of whether it's launched from Visual Studio or not).

Be aware that applications running with Administrative privileges cannot be debugged from applications that are not running as Administrator. Meaning if you want to debug your application, you'll also have to run Visual Studio as Administrator.

Personally, I would suggest that you don't require Administrator privileges in your application and instead use an out-of-process COM object that is marked as Administrator to perform Administrative tasks. That way, your app can spend most of it's time as a non-Administrator and only elevate when actually required. See here for more information on that.

Dean Harding
I agree with paragraphs 1 and 2; however I do not agree at all with the out of process COM object. Unless you consider your security boundaries very carefully it's probably safer to run as administrator for the entire app.
Joshua
The mainfest file works, but doing some tricks in the post compiler. I've tried add it directly from proyect properties > application > view windows settings and unncommenting the uac rules, but that doesn't work...when it should.
Sein Kraft
So... elevating the program is a bit like `sudo`, while elevating only when necessary with an external object is like PolicyKit? :p
Delan Azabani
@Delan: yeah, pretty much. Except in Windows, processes "ask" to be elevated whereas in Linux, if you don't `sudo` and try to do something administer-y, then it simply fails.
Dean Harding
PArtitioning is often a good idea, but into a COM object would not be my first choice. Into another exe is much less work and more importantly you put the manifest on the other exe so it describes itself as needing to elevate. The COM way it's the calling code who is in charge of elevation level. Less encapsulated.
Kate Gregory
@Kate: that's true, though COM does provide the advantage of "free" marshalling of method calls, which makes some things a little easier. I guess it just depends on the situation.
Dean Harding

related questions