2

I noticed that Windows 10 (at least the current stable build 1607) does not properly escape filenames when you try to open a PowerShell script (.ps1) via context menu » Edit.

While ampersand and spaces are treated correctly, Windows cannot open a file whose name has commas - the file name is truncated at the comma.

enter image description here

Resulting error

enter image description here

I am looking for some solution to this problem, whether via a registry fix or a way to add quotes, to escape the comma or anything else.

  • I get the same thing. Using open with > notepad seems to work, though. But yeah, Windows is definitely not handling commas correctly. – Narzard Aug 19 '16 at 19:12
5
+50

You need to change value in that registry key HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Microsoft.PowerShellScript.1\Shell\Edit\Command from "C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe" "%1" to "C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe" """%1""". Or you can use following PowerShell command to do that:

Set-ItemProperty HKLM:\SOFTWARE\Classes\Microsoft.PowerShellScript.1\Shell\Edit\Command '(default)' '"C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe" """%1"""'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.