Wednesday, June 11, 2014

“Run as Administrator” the easy way

We live in a world that is run via PowerShell and how often have you not forgot to run his PowerShell script as "run as administrator"? But there are a few tricks in Windows so that it become easy.

As you probably already, how to start a problem with administrative privileges by right-clicking on a program/shortcut and select "Run as Administrator".
clip_image001

But did you know that by holding ctrl+shift down, you can obtain the same?

You can either double-click on a program/​​shortcut while holding ctrl+shift down or hit enter, it is the same.

Another trick is to make a shortcut to your program. Because on a shortcut, you can choose whether it always should "run as administrator"

How do you know about a problem running under the administrator context?

Look up at the program title bar. It says "Administrator" if it is running under sub-administrator context. This works not only for PowerShell command prompt but also for e.g. visual studio.

Untitled3

1 comment:

  1. I presume you mean CTRL+SHIFT not SHIT as you wrote several times ;-)

    I usually do this in either a batch file or PowerShell using the RunAs verb:
    Start-Process powershell.exe -Verb RunAs
    Which you also can feed an -ArgumentList

    If you need to check in a script it it is being executed by an administrator you can do the following check

    $user = [Security.Principal.WindowsIdentity]::GetCurrent();
    (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)

    ReplyDelete