Pablo Galiano : How do I know if Visual Studio is running in elevated mode

Subscriptions

<March 2010>
SuMoTuWeThFrSa
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

News

Subscribe to Pablo Galiano by Email

Post Categories

How do I know if Visual Studio is running in elevated mode

My fourth How do I is up.

Scenario

Let's say that we want need to check if Visual Studio is running in elevated mode because there are some specific actions that we need to perform that need those permissions. The focus of this How do I tackles this scenario.

 

Interfaces and classes needed

 

Code snippet

    IVsShell3 shell = serviceProvider.GetService(typeof(SVsShell)) as IVsShell3;

 

    bool elevated;

 

    shell.IsRunningElevated(out elevated);

 

    if(!elevated)

    {

        //Visual Studio is not running in elevated mode, let's restart it

        shell.RestartElevated();

    }

 

Assemblies needed

  • Microsoft.VisualStudio.Shell.Interop.9.0

 

Stay tuned,

Pablo

posted on Tuesday, August 19, 2008 12:08 PM by pga

What do you think?

(required) 
required 
optional
required