PowerShell / PowerShell Public
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'Run With PowerShell 7' Right-Click Context Menu is Not Available if Default Program Is Not Notepad #14216
Comments
|
I have the same problem. |
1 similar comment
|
I have the same problem. |
|
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. |
|
Just had this on 7.2.2 |
|
@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. |
|
In powershell ad admin: |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.


Steps to reproduce
When installing PowerShell 7 (MSI Version), the installer allows the following option:
Add 'Run with PowerShell 7' context menu for PowerShell filesScreenshot 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 C ('Run with PowerShell 7' not available):

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.exeThis 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
The text was updated successfully, but these errors were encountered: