Advertisement

Add PowerShell As Administrator Context Menu in Windows 10

PowerShell is an advanced form of command prompt. It is extended with a huge set of ready-to-use cmdlets and comes with the ability to use .NET framework/C# in various scenarios. In this article, we'll see how to add "Open PowerShell here as administrator" to the context menu in Windows 10.

Open PowerShell Here As Administrator
Adding this command to the context menu will allow you to quickly open a new elevated PowerShell instance in the current directory that you right clicked on or are browsing with File Explorer.

To add "Open PowerShell here as administrator" to the context menu in Windows 10, do the following.

Advertisеment

Apply the Registry tweak listed below. Paste its contents inside Notepad and save as a *.reg file.

Powershell Admin Context Menu Tweak Contents

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\OpenElevatedPS]
@="Open PowerShell here as administrator"
"Icon"="powershell.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\shell\OpenElevatedPS\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/c,pushd %V && powershell' -Verb RunAs\""

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenElevatedPS]
@="Open PowerShell here as administrator"
"Icon"="powershell.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenElevatedPS\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/c,pushd %V && powershell' -Verb RunAs\""

[HKEY_CLASSES_ROOT\Drive\shell\OpenElevatedPS]
@="Open PowerShell here as administrator"
"Icon"="powershell.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\Drive\shell\OpenElevatedPS\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/c,pushd %V && powershell' -Verb RunAs\""

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenElevatedPS]
@="Open PowerShell here as administrator"
"Icon"="powershell.exe"
"HasLUAShield"=""

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenElevatedPS\command]
@="PowerShell -windowstyle hidden -Command \"Start-Process cmd.exe -ArgumentList '/s,/c,pushd %V && powershell' -Verb RunAs\""

In Notepad, press Ctrl + S or execute the File - Save item from the File menu. This will open the Save dialog. There, type or copy-paste the name "ps.reg" including quotes.Powershell Admin Context Menu Save Tweak

Double quotes are important to ensure that the file will get the "*.reg" extension and not *.reg.txt. You can save the file to any desired location, for example, you can put it in your Desktop folder.

Double click the file you created, confirm the import operation and you are done.Powershell Admin Context Menu Import Tweak

Now right-click any folder.Open PowerShell Here As Administrator

You can enable this context menu quickly with Winaero Tweaker. It comes with the following option:

Winaero Tweaker Powershell Menu

You can download the app from here:

Download Winaero Tweaker

To save your time, I made ready-to-use Registry files. You can download them here:

Download Registry Files

The undo tweak is included.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Advertisеment

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

8 thoughts on “Add PowerShell As Administrator Context Menu in Windows 10”

    1. Hello,
      Please tell me:
      Which OS version you are running?
      Which method you have used to add the context menu command?

  1. Hi Sergey
    This one has always opened command prompt for me, ever since it was first added. Now on Win10 Enterprise 1803, still instantly closes powershell and automatically opens cmd instead. Hope you get to work on a solution. Thanks for all the effort, been using WInaero for years, always appreciated.

  2. Still doesn’t work.

    Shell opens for a short moment, then closes and an elevated command prompt appears in it’s place.

    Win10Pro x64 2004

  3. Looks like I was a bit hasty.

    It does indeed open PS within the cmd window.
    Overlooked it at first since I was expecting the usual blue PS window.

    Thanks Sergey, for all the work you put into this great piece of software.

  4. I was able to get the command to open a PS window (rather than a CMD window running PS) by changing all of the lines starting with @ to this:

    @=”powershell -command \”start-process powershell.exe -Verb RunAs -ArgumentList \\\”-noexit -command Set-Location ‘%V’\\\”\””

    It’s weird using powershell to start a process that’s powershell, but it works, although you will see a bunch of windows opening and closing.

Leave a Reply

Your email address will not be published.

css.php
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.