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