Skip to content

'Run With PowerShell 7' Right-Click Context Menu is Not Available if Default Program Is Not Notepad #14216

Open

Description

@DesertBear

Steps to reproduce

When installing PowerShell 7 (MSI Version), the installer allows the following option:

Add 'Run with PowerShell 7' context menu for PowerShell files

Screenshot A:
Screenshot A

However, this option is only available if .ps1 files are set to open in Notepad (the default). If .ps1 files are set to open in Visual Studio Code by default, then this option disappears from the context menu.

Screenshot B ('Run with PowerShell 7' available):
Screenshot B

Screenshot C ('Run with PowerShell 7' not available):
Screenshot C

Most of the time I want .ps1 files to open in Visual Studio Code and therefore want to keep that as the default program for opening .ps1 files. However, doing so means I loose the right-click context menu for when I want to run certain .ps1 files directly in PowerShell 7 from their location. It would be better if it was always possible to right-click a .ps1 file and select 'Run with PowerShell 7', even when another application – such as Visual Studio Code – is the default program for that file type.

For PowerShell 7 (MSI Version), it's possible to work around this to an extent by using the [Right-click > Open with] menu item, selecting the PowerShell 7 pwsh.exe and then use that in conjunction with using $PSScriptRoot as the path in the script. However, for PowerShell 7 (Microsoft Store Version) it's a bit more complicated. Not only does the store version not have the 'Run with PowerShell 7' context menu option at all, but using the 'Open with' menu work-a-round is more burdensome as the file path contains the version number in it. I.E.

C:\Program Files\WindowsApps\Microsoft.PowerShell_7.1.0.0_x64__8wekyb3d8bbwe\pwsh.exe

This means the file path will keep changing every time PowerShell is updated and will therefore need to be manually set again every time PowerShell is updated.

Expected behavior

As long as PowerShell 7 is installed on the machine, the 'Run with PowerShell 7' context menu should always be available in the right-click menu for PowerShell .ps1 files, regardless of whether another application – such as Visual Studio Code – is the default program for that file type.

The 'Run with PowerShell 7' context menu should also be available to people who are using the Microsoft Store version of PowerShell 7.

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.0
PSEdition                      Core
GitCommitId                    7.1.0
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Activity

  1. added
    Issue-Question
    on Nov 21, 2020
  2. added
    WG-Maintainers-Build
    on Nov 22, 2020
  3. mwilsonray commented on Nov 16, 2021

    @mwilsonray

    I have the same problem.

  4. chaoscreater commented on Mar 31, 2022

    @chaoscreater

    Had the same issue, except that my .ps1 association was already set to Notepad.

    Ended up modifying the reg key and now I got it working again. This is tested on the latest Win11 build as of this writing.

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1]
    
    [HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell]
    
    [HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\Edit]
    "NoSmartScreen"=""
    
    [HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\Edit\Command]
    @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell_ise.exe\" \"%1\""
    
    [HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\RunPowershell5AsAdmin]
    @="Run with Powershell 5 as Admin"
    
    [HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\RunPowershell5AsAdmin\command]
    @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" \"-Command\" \"\"& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy RemoteSigned -File \\\"%1\\\"' -Verb RunAs}\""
    
    [HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\RunPowershell7]
    @="Run with Powershell 7 - non admin"
    
    [HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\RunPowershell7\Command]
    @="C:\\Program Files\\PowerShell\\7\\pwsh.exe -Command \"$host.UI.RawUI.WindowTitle = 'PowerShell 7 (x64)'; if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\""
    
    [HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\RunPowershell7AsAdmin]
    @="Run with Powershell 7 as Admin"
    
    [HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\RunPowershell7AsAdmin\Command]
    @="\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\" \"-Command\" \"\"& {Start-Process pwsh.exe -ArgumentList '-ExecutionPolicy RemoteSigned -File \\\"%1\\\"' -Verb RunAs}\""
    
    [HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\Windows.PowerShell.Run]
    "MUIVerb"=hex(2):40,00,22,00,25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,\
      6f,00,6f,00,74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,\
      00,5c,00,77,00,69,00,6e,00,64,00,6f,00,77,00,73,00,70,00,6f,00,77,00,65,00,\
      72,00,73,00,68,00,65,00,6c,00,6c,00,5c,00,76,00,31,00,2e,00,30,00,5c,00,70,\
      00,6f,00,77,00,65,00,72,00,73,00,68,00,65,00,6c,00,6c,00,2e,00,65,00,78,00,\
      65,00,20,00,22,00,2c,00,2d,00,31,00,30,00,38,00,00,00
    @="Run with Powershell 5"
    
    [HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\Windows.PowerShell.Run\Command]
    @="\"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" \"-Command\" \"if((Get-ExecutionPolicy ) -ne 'AllSigned') { Set-ExecutionPolicy -Scope Process Bypass }; & '%1'\""
    
    

    image

  5. twomm commented on Apr 1, 2022

    @twomm

    Just had this on 7.2.2

  6. asheroto commented on Apr 6, 2022

    @asheroto

    chaoscreater thanks for posting your reg entry! Added it to my system and it works great.

    I'll probably write an article about this and reference this post. 😀

  7. added
    Resolution-No Activity
    on Nov 16, 2023
  8. soredake commented on Nov 16, 2023

    @soredake

    Still wanted.

  9. eterna1-0blivion commented on Nov 21, 2023

    @eterna1-0blivion

    I also encountered this problem and decided to fix it. Beautifully fix it.

    Here's what it looks like in Windows Explorer:

    1

    And in Registry Editor:

    2

    Here's a link to the registry file: .reg file

    Registry file has been updated to version 2.0;
    The current result looks different from what is shown in the screenshots, but don't worry - the script hasn't lost its core functions.
    This affected the implementation of the menu and its operating logic - aimed at simplifying the script, increasing its reliability, and improving compatibility with external shells (like DirectoryOpus). Changelog for version 2.0 availible in comments for gist repository.

    Or simply type the following in PowerShell (or download a script): .ps1 file

    # author: eterna1_0blivion & soredake
    
    # Get a link to the Registration Entries file
    $link = "https://gist.github.com/eterna1-0blivion/70c1e5b14c7cfa8c6b6d574eb38fd27e/raw/context_pwsh_fix.reg"
    
    # Install them into Registry using PowerShell
    Invoke-WebRequest -Uri "$link" -OutFile "$env:TEMP/context_pwsh_fix.reg"
    reg import "$env:TEMP/context_pwsh_fix.reg"
    
    # Notify the user before exiting the program
    Read-Host -Prompt "Press Enter to exit"
    Exit
  10. asheroto commented on Nov 21, 2023

    @asheroto

    Oh that's just beautiful. Thank you Vlad is Law (@eterna1-0blivion)!!!!!

  11. removed
    Resolution-No Activity
    on Nov 28, 2023
  12. kspdrgn commented on Apr 4, 2024

    @kspdrgn

    Solution posted by eterna1_0blivion & soredake works, but in Windows 11 it removes the "Run with Powershell" (5) command entirely from the 1st level of context menu, and you must use "Show More Options" to get to the real context menu and then the new Powershell menu is visible.

  13. asheroto commented on Apr 4, 2024

    @asheroto

    kspdrgn (@kspdrgn) Yes, unfortunately that's typical behavior. You can disable the default "Show More Options" though (so it'll show full context menu)...

    https://www.elevenforum.com/t/disable-show-more-options-context-menu-in-windows-11.1589/

  14. added
    KeepOpen
    WG-NeedsReview
    on Apr 29, 2024
  15. MikeWilliams-UK commented on Aug 8, 2025

    @MikeWilliams-UK

    I have the same problem, but in my case .ps1 is associated with PowerShell ISE

  16. MikeWilliams-UK commented on Aug 8, 2025

    @MikeWilliams-UK

    Registry tweak by Vlad is Law (@eterna1-0blivion) works a treat.

    However if I have "dir C:\Temp" in my script it shows as
    Image
    When run via right click menu

    Instead of
    Image
    When run in interactive mode

    Is this a problem with the right click menu or something deeper?

  17. eterna1-0blivion commented on Aug 8, 2025

    @eterna1-0blivion

    Hello, Mike Williams (@MikeWilliams-UK)

    1. Does this issue occur in both versions of PowerShell (5 and 7)?

    2. Are you running the script with or without administrator privileges?

    3. Does this issue occur if you run the script as a command within PowerShell (pwsh {PATH/TO/YOUR/SCRIPT}.ps1)?

  18. MikeWilliams-UK commented on Aug 8, 2025

    @MikeWilliams-UK

    The script has to be run with version 7

    Not running as admin

    pwsh {PATH/TO/YOUR/SCRIPT}.ps1 has the same effect

    I have determined that it has something to do with me calling

    Connect-AzAccount -TenantId {guid}

  19. MikeWilliams-UK commented on Aug 8, 2025

    @MikeWilliams-UK

    Not sure what is happening, but if I change my

    dir C:\Temp

    to

    dir C:\Temp | Format-Table

    I get the usual output

  20. oleksiivasylenko commented on Aug 21, 2025

    @oleksiivasylenko

    Just installed PS 7.5.2 And see that "Run with powershell 7" is missing.

  21. eterna1-0blivion commented on Sep 14, 2025

    @eterna1-0blivion

    Just installed PS 7.5.2 And see that "Run with powershell 7" is missing.

    You can use this solution.

  22. SamErde commented on Nov 16, 2026

    @SamErde

    This issue seems especially relevant now that PowerShell 7.7 has transitioned to MSIX packaging.

    I've referenced it in the main MSIX migration tracking issue (#27565), suggesting that Explorer context-menu parity be tracked as a distinct compatibility gap.

    I think the original request identifies the right behavior: retain the user's preferred .ps1 editor for double-clicks while providing an independent Run with PowerShell 7 context-menu action that works with MSIX installations and survives package updates.

    The historical MSIX context-menu proposal in #10892 is also relevant, including the PowerShell Committee's earlier suggestion to explore a separate module.

    Hopefully this can be addressed as part of the broader packaging transition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-QuestionKeepOpenWG-Maintainers-BuildWG-NeedsReview

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions