C#: Programmatically “Run As Administrator”

A few days ago I wanted to write to hosts, a HOSTS file in system32 used by Microsoft TCP/IP for Windows. Since this file is protected, you can edit it in administrative mode only. This means the user has to right click it and select “Run as administrator” for your project to run correctly. Fortunately there is a solution. The following code will request admin access from the user, and rerun it’s self in admin mode:

Continue reading

Advertisements

Visual Studio 2012.4, “Run As Administrator” -> “The application cannot start” error

After a good 2 hours of searching what the **** happened and Visual Studio stopped working, I finally found a working solution…

Just copy all dte*.olb files, from C:\Program Files (X86)\Common Files\Microsoft Shared\MSEnv to C:\Program Files X86\Microsoft Visual Studio 9.0\Common7\IDE.

Just for the record, I tried “devenv /resetuserdata” and deleting the involved registry keys with no luck at all. I end up using Process Monitor after reading this post: http://blogs.msdn.com/b/visualstudio/archive/2009/10/29/how-to-fix-the-application-cannot-start-error.aspx?PageIndex=4.

With a little luck and a lot of tries,  I got a headache and a working studio.