Skip to content
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

VSCode clobbers "Run with PowerShell" in Windows Explorer context menu #64815

Closed
rjmholt opened this issue Dec 11, 2018 · 17 comments
Closed

VSCode clobbers "Run with PowerShell" in Windows Explorer context menu #64815

rjmholt opened this issue Dec 11, 2018 · 17 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@rjmholt
Copy link

rjmholt commented Dec 11, 2018

From @mjbvz on April 20, 2017 22:16

From @rambutan2000 on April 20, 2017 22:9

  • VSCode Version: Code 1.11.2 (6eaebe3, 2017-04-13T08:03:11.395Z)
  • OS Version: Windows_NT ia32 10.0.14393
  • Extensions:
Extension Author Version
python donjayamanne 0.6.2
PowerShell ms-vscode 0.12.2

After I installed the powershell extension for VS code (from within VS code the usual way) it removed the run powershell context menu option in Windows Explorer

Steps to Reproduce:

  1. Install the powershell extensions
  2. In windows explorer, right-click on a *.ps1 file, the "Run Powershell script" content menu item is missing

Copied from original issue: #25099

Copied from original issue: PowerShell/vscode-powershell#692

@rjmholt
Copy link
Author

rjmholt commented Dec 11, 2018

From @mjbvz on April 20, 2017 22:16

From @rambutan2000 on April 20, 2017 22:12

Looks like others have had a similar problem, looks like its to do with changing the default editor of ps1 files
https://community.spiceworks.com/topic/1083434-can-t-recover-run-with-powershell-context-menu-entry

@rjmholt
Copy link
Author

rjmholt commented Dec 11, 2018

From @daviwil on April 20, 2017 22:18

Isn't this caused by VS Code though? The PowerShell extension doesn't mess with default file configurations in Windows.

@rjmholt
Copy link
Author

rjmholt commented Dec 11, 2018

From @rambutan2000 on April 20, 2017 22:21

The root cause is some kind of shell bug, but maybe the VS code extension should not automatically associate VS Code with .ps1 files. I've attached a .reg file which fixes the issue. Maybe compare what the extension is doing to register ps1 files with against the reg file contents.

I'm adding the contents of the files since this form won't let me attach the file, even though it's zipped :/


Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT.ps1]

[HKEY_CLASSES_ROOT.ps1]
@="Microsoft.PowerShellScript.1"

[-HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1]

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1]
"EditFlags"=dword:00020000
"FriendlyTypeName"=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,22,00,2c,00,20,00,2d,00,31,00,30,00,33,00,00,00

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\DefaultIcon]
@=""C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe",1"

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell]
@="Open"

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\0]
"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,22,00,2c,00,2d,00,31,00,30,00,38,00,00,00

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\0\Command]
@=""C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-file" "%1""

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit]

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Edit\Command]
@=""C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe" "%1""

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open]

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command]
@=""C:\Windows\System32\notepad.exe" "%1""

[-HKEY_CLASSES_ROOTS\SystemFileAssociations.ps1]

[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts.ps1]

@rjmholt
Copy link
Author

rjmholt commented Dec 11, 2018

From @daviwil on April 20, 2017 22:27

Definitely a shell bug, but the PowerShell extension itself doesn't touch the system's file associations. In theory this should be happening when you install VS Code itself, not the PowerShell extension. Did the problem only occur after you installed the PowerShell extension? Could you double-check?

@rjmholt
Copy link
Author

rjmholt commented Dec 11, 2018

From @rambutan2000 on April 20, 2017 22:46

I'm 90% it was after the powershell extension install. I tried to open a ps1 file then VS code showed the recommendation bar above the code view. I then installed the extension and tried to run the ps1 file from win explorer. I'd been running ps1 files earlier today and this is the only change to my system.

@rjmholt
Copy link
Author

rjmholt commented Dec 11, 2018

From @daviwil on April 20, 2017 22:49

That's extremely strange if so. I wonder if VS Code has some logic for associating the file extension when a language extension for a known file type is installed.

FWIW, the only place where the PowerShell file extensions are registered is in the built-in PowerShell syntax extension: https://github.com/Microsoft/vscode/blob/master/extensions/powershell/package.json#L9

@rjmholt
Copy link
Author

rjmholt commented Dec 11, 2018

From @mpearon on May 17, 2017 15:52

I don't think I agree with the OP's observations here. I've only seen this behavior if I changed the default association of PS1s, and I've installed on every machine I've has the opportunity to.
I use a registry modification similar to the one listed above.

@rjmholt
Copy link
Author

rjmholt commented Dec 11, 2018

From @JackUkleja on July 10, 2017 0:2

I just noticed today that my "Run with PowerShell" shell menu item is missing. I'm using VSCode 1.13.1 with the 1.4.1 PowerShell extension.

@rjmholt
Copy link
Author

rjmholt commented Dec 11, 2018

From @JackUkleja on July 10, 2017 0:10

@rambutan2000 Your .reg script didn't seem to fix the issue for me. Strange.

@rjmholt
Copy link
Author

rjmholt commented Dec 11, 2018

From @f0nt4 on June 13, 2018 17:44

I don't think this is an issue of the extension, but from Code itself.
After opening a ps1 file with "Windows PowerShell ISE", the option "Run with PowerShell" is back.
As soon as you open a ps1 with code, the option disappears.
After that when you again open with PowerShell ISE, the option returns
and so it continues.
This also happens when the PowerShell addon is not installed.

@rjmholt
Copy link
Author

rjmholt commented Dec 11, 2018

From @BrianMakes on December 11, 2018 13:35

I am experiencing the same issue @f0nt4 describes.

If VS Code is associated with the PS1 file type, the following behavior occurs:

"Run with PowerShell" shell menu item is missing. (after installing VS Code or Powershell Extension)
Opening PS1 file in ISE returns the "Run with PowerShell" shell menu item.
Opening PS1 file in VS Code removes the menu item.

Associating the PS1 filetype with something else (I tested with Notepad) correct the issue.

@rjmholt
Copy link
Author

rjmholt commented Dec 11, 2018

This also happens when the PowerShell addon is not installed.

It sounds like this issue should be moved to VSCode. One sec

@rjmholt rjmholt changed the title installing powershell extension for VS code removes run script context menu VSCode clobbers "Run with PowerShell" in Windows Explorer context menu Dec 11, 2018
@BrianMakes
Copy link

I am happy to provide additional info or testing if it would be helpful.

I use the default "Run with Powershell" menu as well as a couple of custom options manually added to the PS1 associations in the registry. Association VS Code to .ps1 causes them all to disappear. But its non destructive, they all return when the association to VS VCode is removed.

@bpasero bpasero assigned joaomoreno and unassigned bpasero Dec 17, 2018
@joaomoreno
Copy link
Member

I wonder if VS Code has some logic for associating the file extension when a language extension for a known file type is installed.

It doesn't. Also, VS Code only writes to the registry during its setup, never at runtime.

This also happens when the PowerShell addon is not installed.

@f0nt4 Please provide steps, if that's the case, as I can't reproduce that.

@joaomoreno joaomoreno added the info-needed Issue requires more information from poster label Dec 17, 2018
@vscodebot vscodebot bot closed this as completed Dec 24, 2018
@vscodebot
Copy link

vscodebot bot commented Dec 24, 2018

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@Fonta
Copy link

Fonta commented Dec 24, 2018

@joaomoreno All I did was install VS Code and selected the context menu integration. After that the run with PowerShell option is gone from the context menu on .ps1 files.

@miicah
Copy link

miicah commented Jan 23, 2019

I have the same bug.

Installed VS Code, installed the PowerShell plugin, associated VSCode with PS1 files and now the right click context menu has gone.

@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

7 participants
@joaomoreno @bpasero @Fonta @rjmholt @miicah @BrianMakes and others