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

Subscriptions

<September 2010>
SuMoTuWeThFrSa
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

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