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.

Advertisment

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.

Advertisment

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

  1. Jara

    hi, i tried it, but WPS window immediately disappears – am i doing something wrong?

    Reply
  2. Piohm

    Hello!
    Same experience as Jara. PowerShell closes in less than 0,25 second and a classic command prompt opens afterward.

    Reply
    1. Sergey Tkachenko Post author

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

      Reply
  3. Michaël Polla

    Like the others have mentioned, it opens a command prompt ; in fact, a command prompt running PowerShell.

    Reply
  4. Jordan

    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.

    Reply
  5. Sven

    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

    Reply
  6. Sven

    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.

    Reply
  7. Ran

    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.

    Reply

Leave a Reply

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