Add Open PowerShell window here as administrator in Windows 10  

Page 1 of 10 123 ... LastLast
    Add Open PowerShell window here as administrator in Windows 10

    Add Open PowerShell window here as administrator in Windows 10

    How to Add Open PowerShell window here as administrator context menu in Windows 10
    Published by Category: Customization
    20 Dec 2023
    Designer Media Ltd

    How to Add "Open PowerShell window here as administrator" context menu in Windows 10


    Windows 10 comes with Windows PowerShell 5.0 included.

    Windows PowerShell is a task-based command-line shell and scripting language designed especially for system administration. Built on the .NET Framework, Windows PowerShell helps IT professionals and power users control and automate the administration of the Windows operating system and applications that run on Windows.

    For more details about Windows PowerShell, see:

    This tutorial will show you how to add or remove a Open PowerShell window here as administrator context menu for all users in Windows 10 and Windows 11.

    You must be signed in as an administrator to add, remove, or use the "Open PowerShell window here as administrator" context menu.

    The "Open PowerShell window here as administrator" context menu will be available when you right click or shift + right click on a folder, drive, or mapped network drive and when you right click or shift + right click on the background of a folder, drive, mapped network drive, library, or desktop.


    Thank you to LesFerch for updating the command used in this context menu to be more compatible and usable.


    EXAMPLE: "Open PowerShell window here as administrator" context menu
    Add Open PowerShell window here as administrator in Windows 10-open_powershell_here_as_admin_context_menu.png
    Add Open PowerShell window here as administrator in Windows 10-open_powershell_window_here_as_administrator.png



    Here's How:

    1 Do step 2 (add-right click), step 3 (add-Shift+right click) , or step 4 (remove) below for what you would like to do.


    2 To Add Right Click "Open PowerShell window here as administrator" Context Menu

    A) Click/tap on the Download button below to download the file below, and go to step 5 below.

    Add_Open_PowerShell_window_here_as_administrator_context_menu.reg

    Download

    (Content of REG file for reference)
    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShellAsAdmin]
    @="Open PowerShell window here as administrator"
    "Extended"=-
    "HasLUAShield"=""
    "Icon"="powershell.exe"
    
    [HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShellAsAdmin\command]
    @="cmd /c reg add hkcu\\software\\_dir /d \"%v\" /f & start powershell -WindowS H -noP -c Start-Process -v RunAs powershell.exe '-noL -noE -c cd -literalP (gp hkcu:\\software\\_dir).\\\"\\\"\\\"(default)\\\"\\\"\\\"; ri hkcu:\\software\\_dir'"
    
    
    [HKEY_CLASSES_ROOT\Directory\shell\PowerShellAsAdmin]
    @="Open PowerShell window here as administrator"
    "Extended"=-
    "HasLUAShield"=""
    "Icon"="powershell.exe"
    
    [HKEY_CLASSES_ROOT\Directory\shell\PowerShellAsAdmin\command]
    @="cmd /c reg add hkcu\\software\\_dir /d \"%v\" /f & start powershell -WindowS H -noP -c Start-Process -v RunAs powershell.exe '-noL -noE -c cd -literalP (gp hkcu:\\software\\_dir).\\\"\\\"\\\"(default)\\\"\\\"\\\"; ri hkcu:\\software\\_dir'"
    
    
    [HKEY_CLASSES_ROOT\Drive\shell\PowerShellAsAdmin]
    @="Open PowerShell window here as administrator"
    "Extended"=-
    "HasLUAShield"=""
    "Icon"="powershell.exe"
    
    [HKEY_CLASSES_ROOT\Drive\shell\PowerShellAsAdmin\command]
    @="cmd /c reg add hkcu\\software\\_dir /d \"%v\" /f & start powershell -WindowS H -noP -c Start-Process -v RunAs powershell.exe '-noL -noE -c cd -literalP (gp hkcu:\\software\\_dir).\\\"\\\"\\\"(default)\\\"\\\"\\\"; ri hkcu:\\software\\_dir'"
    
    
    [-HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\PowerShellAsAdmin]
    
    
    ; To allow mapped drives to be available in elevated PowerShell
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
    "EnableLinkedConnections"=dword:00000001


    3 To Add Shift + Right Click "Open PowerShell window here as administrator" Context Menu

    A) Click/tap on the Download button below to download the file below, and go to step 5 below.

    Add_Shift+Open_PowerShell_window_here_as_administrator_context_menu.reg

    Download

    (Content of REG file for reference)
    Code:
    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShellAsAdmin]
    @="Open PowerShell window here as administrator"
    "Extended"=""
    "HasLUAShield"=""
    "Icon"="powershell.exe"
    
    [HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShellAsAdmin\command]
    @="cmd /c reg add hkcu\\software\\_dir /d \"%v\" /f & start powershell -WindowS H -noP -c Start-Process -v RunAs powershell.exe '-noL -noE -c cd -literalP (gp hkcu:\\software\\_dir).\\\"\\\"\\\"(default)\\\"\\\"\\\"; ri hkcu:\\software\\_dir'"
    
    
    [HKEY_CLASSES_ROOT\Directory\shell\PowerShellAsAdmin]
    @="Open PowerShell window here as administrator"
    "Extended"=""
    "HasLUAShield"=""
    "Icon"="powershell.exe"
    
    [HKEY_CLASSES_ROOT\Directory\shell\PowerShellAsAdmin\command]
    @="cmd /c reg add hkcu\\software\\_dir /d \"%v\" /f & start powershell -WindowS H -noP -c Start-Process -v RunAs powershell.exe '-noL -noE -c cd -literalP (gp hkcu:\\software\\_dir).\\\"\\\"\\\"(default)\\\"\\\"\\\"; ri hkcu:\\software\\_dir'"
    
    
    [HKEY_CLASSES_ROOT\Drive\shell\PowerShellAsAdmin]
    @="Open PowerShell window here as administrator"
    "Extended"=""
    "HasLUAShield"=""
    "Icon"="powershell.exe"
    
    [HKEY_CLASSES_ROOT\Drive\shell\PowerShellAsAdmin\command]
    @="cmd /c reg add hkcu\\software\\_dir /d \"%v\" /f & start powershell -WindowS H -noP -c Start-Process -v RunAs powershell.exe '-noL -noE -c cd -literalP (gp hkcu:\\software\\_dir).\\\"\\\"\\\"(default)\\\"\\\"\\\"; ri hkcu:\\software\\_dir'"
    
    
    [-HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\PowerShellAsAdmin]
    
    
    ; To allow mapped drives to be available in elevated PowerShell
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
    "EnableLinkedConnections"=dword:00000001


    4 To Remove "Open PowerShell window here as administrator" Context Menu

    This is the default setting.

    A) Click/tap on the Download button below to download the file below, and go to step 5 below.

    Remove_Open_PowerShell_window_here_as_administrator_context_menu.reg

    Download


    (Content of REG file for reference)
    Code:
    Windows Registry Editor Version 5.00
    
    [-HKEY_CLASSES_ROOT\Directory\Background\shell\PowerShellAsAdmin]
    
    [-HKEY_CLASSES_ROOT\Directory\shell\PowerShellAsAdmin]
    
    [-HKEY_CLASSES_ROOT\Drive\shell\PowerShellAsAdmin]
    
    [-HKEY_CLASSES_ROOT\LibraryFolder\Background\shell\PowerShellAsAdmin]

    5 Save the .reg file to your desktop.

    6 Double click/tap on the downloaded .reg file to merge it.

    7 When prompted, click/tap on Run, Yes (UAC), Yes, and OK to approve the merge.

    8 You can now delete the downloaded .reg file if you like.


    That's it,
    Shawn Brink






  1. EDP
    Posts : 8
    Windows 10 Education
       #1

    I found the /k switch in the cmd call to launch PowerShell is not handy for me. Let me illustrate an example:
    Because I have my hands on the keyboard when using PS, quitting is faster by typing exit than with the mouse to close the PS window, which actually is cmd running PS. So, when I type exit PS quits and cmd is still there, so I'd have to type exit twice to actually close the window (Alt+F4 doest not work in PS). This can be fixed by changing the /k switch to /c, which stops cmd execution after PS quits. Is this always the case and if so, would you consider integrating this change in the .reg files on tenforums.com?
      My Computer


  2. Posts : 68,543
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #2

    Hello EDP, :)

    Odd. It closed for me, but I have updated the tutorial to use /C for you to help.
      My Computers


  3. Posts : 7,724
    3-Win-7Prox64 3-Win10Prox64 3-LinuxMint20.2
       #3

    Hi,
    This one is
    I'm getting quite a collection of reg files thanks for your generous geekness :)
    Cheers.
      My Computers


  4. Posts : 68,543
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #4

      My Computers


  5. Posts : 2
    Windows 10 x64
       #5

    On my laptop Powershell immediately auto-closes and leaving a command shell running. Tried changing '/c' to '/k', made no difference.
      My Computer


  6. Posts : 68,543
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #6

    Hello flvegat, and welcome to Ten Forums. :)

    Does it look like the example screenshot in the tutorial?

    If so, it's running PowerShell even though it's in a command window instead of the usual blue PowerShell window.
      My Computers


  7. Posts : 1,097
    Windows 10 Home x64 Version 1809 (OS Build 17763.437)
       #7

    You do nice work Shawn. Thanks.
      My Computer


  8. Posts : 2
    Windows 10 x64
       #8

    Sorry, didn't notice the Powershell prompt
      My Computer


  9. Posts : 68,543
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #9

    No problem. I just wanted to make sure it was working properly for you. :)
      My Computers


 

Tutorial Categories

Add Open PowerShell window here as administrator in Windows 10 Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:20.
Find Us




Windows 10 Forums