Search code examples
powershellvisual-studio-codewindows-explorer

Execute Powershell from File Explorer after installing VS Code


VS Code is trying to position itself as a new way to work with Powershell, and one of the changes it makes upon installation is to replace the File Explorer context menu option "Run with PowerShell" on .ps1 files with a new "Open with Code" option instead.

Is there a way to remove the "Open with Code" option and replace it with the old "Run with PowerShell" option? I assume this would involve the registry somehow but I don't know enough about the registry in general to do it safely.


Solution

  • VS Code is not really positioning itself as the new way to work with PowerShell, it will be the only "built-in" way with Windows to work with it because the PowerShell ISE is being depreciated.

    Either way, VS Code did not cause that option to disappear. I have VS Code and the PS extension on my machine and still have access to both options:

    enter image description here

    When you install VS Code you are prompted to add the right-click menu options, so if you opt'ed into those then it is not what removed your "Run with PowerShell" option.

    enter image description here

    If you want to remove those right-click options then you would have to uninstall VS Code and install it again, making sure those options are not checked.

    To restore your menu option to Run with PowerShell verify you have not changed the default program for PowerShell files (e.g. ps1). If you set that to VS Code it will cause the option to be removed from your right-click menu. You can restore it by changing the default program in Windows back to Notepad.

    enter image description here