How to open PowerShell as administrator

During the course of making adjustments to various Windows settings, you may need to open PowerShell as administrator dozens of times. Here’s how to do that quickly at the right path.

PowerShell is an advanced shell for doing operations in Windows using the command line, that is, by typing or pasting commands instead of using the user interface. It is much more powerful than the command prompt, almost like a full-fledged programming language, but is also equally complex.

Opening PowerShell is as simple as typing Powershell into Start search and pressing Enter. However opening it at the right path, or opening it as administrator may be tricky for some inexperienced users. Similarly, opening it as administrator and at the right path may be even trickier. Here are some ways to do that.

Open it at the right path

Just like for the command prompt, the easiest way to do this is to simply open any folder path in File Explorer. Then focus on the address bar by clicking on it or press Alt+D. Type Powershell and press Enter. PowerShell will open at the folder you are currently browsing in Explorer.

Another way is to select the folder where you want to open PowerShell in the left or right pane of Explorer. Then choose File on the Ribbon -> Open Windows PowerShell.

Open PowerShell as admin

In Start search, type powershell and press Ctrl+Shift+Enter to open the appropriate item (x64 or x86 version of PowerShell) as administrator. To open PowerShell as administrator at a specific path, you can use the command on the Explorer Ribbon inside File menu. Or copy the text below into Notepad or your favorite text editor and save it as a .REG file.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\Windows.PowershellAsAdmin]
"CanonicalName"="{ADB73FFC-1568-4D7D-BCD5-6D11A417AF64}"
"CommandStateSync"=""
"Description"="@shell32.dll,-37449"
"ExplorerCommandHandler"="{BF0AC53F-D51C-419F-92E3-2298E125F004}"
"Icon"="imageres.dll,-5373"
"ImpliedSelectionModel"=dword:00000001
"MUIVerb"="@shell32.dll,-37448"
"ResolveLinksInvokeBehavior"=dword:00000003
"ResolveLinksQueryBehavior"=dword:00000000

[HKEY_CLASSES_ROOT\Directory\shell\OpenAdminPSH]
@="Open Windows PowerShell as administrator"
"Icon"="powershell.exe"

[HKEY_CLASSES_ROOT\Directory\shell\OpenAdminPSH\command]
@="PowerShell -Command \"Start-Process cmd -ArgumentList '/s,/k,pushd %V && start PowerShell -NoExit && exit' -Verb RunAs\""

[HKEY_CLASSES_ROOT\Drive\shell\OpenAdminPSH]
@="Open Windows PowerShell as administrator"
"Icon"="powershell.exe"

[HKEY_CLASSES_ROOT\Drive\shell\OpenAdminPSH\command]
@="PowerShell -Command \"Start-Process cmd -ArgumentList '/s,/k,pushd %V && start PowerShell -NoExit && exit' -Verb RunAs\""

Then double-click the REG file to merge it into the Registry. If you want to know more about REG files, see this article. This will add a verb Open Windows PowerShell as administrator to the context menu of a folder, the directory background menu, drives and even your Desktop right click menu.

Open Windows PowerShell as administrator from directory background context menu
Open Windows PowerShell as administrator by right clicking the Desktop

The best thing about it is that it will also work on network paths. If you use the network directory’s background context menu to invoke the verb by right clicking in an empty area, it will directly open at the path you are browsing in Explorer.

PowerShell running as administrator at a network folder path
PowerShell running as administrator at a network folder path

Leave a Reply

Your email address will not be published. Required fields are marked *