winutil icon indicating copy to clipboard operation
winutil copied to clipboard

Shift+Right-Click context menu "Open in Terminal" and "Open in PowerShell" break

Open Compleur opened this issue 4 weeks ago • 2 comments

Describe the bug

Shift+Right-Click context menu "Open in Terminal" and "Open in PowerShell" break with brackets or spaces in folder names. This may be related to 'Set-Location' and/or 'cd' commands

Steps to reproduce

PowerShell Example Error:

  1. Open Folder with a space in the directory location (e.g. "C:\Users\USER\ex ample"
  2. Shift + Right-Click context menu -> "Open PowerShell Window Here"
  3. PowerShell opens and outputs an error:
Set-Location : A positional parameter cannot be found that accepts argument 'ample'.
At line:1 char:1
+ Set-Location -literalPath C:\Users\USER\ex ample
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-Location], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

Note that "Open in Terminal" option works in this example as it should.

Terminal Example Error:

  1. Open Folder with a space in the directory location (e.g. "C:\Users\USER[example"
  2. Right-Click context menu -> "Open in Terminal" 3a. PowerShell opens and defaults to "C:>" 3b. If PowerShell is given the command "cd "C:\Users\USER[example" or "Set-Location "C:\Users\USER[example""
Set-Location : The specified wildcard character pattern is not valid: [example
At line:1 char:1
+ Set-Location "C:\Users\USER\[example"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-Location], WildcardPatternException
    + FullyQualifiedErrorId : RuntimeException,Microsoft.PowerShell.Commands.SetLocationCommand

Note that "Open PowerShell Window Here" option works in this example as it should.

Expected behavior

Powershell Should open with the current working location as it's set specified location

Screenshots

Errors are written out in "Steps to Reproduce"

Additional context

For "Open PowerShell Here," my guess is that a command in the registry is broken due to not including quotation marks. I checked under "HKEY_CLASSES_ROOT\directory\background\shell\Powershell\command" and found the data value " powershell.exe -noexit -command Set-Location -literalPath "%V" ". from online sources I noticed that "%L" would be used, but I'm not sure what the difference is due to my inexpertise in this.

For the bracket wildcard error(?), I am curious if this could be a similar issue? I am out of my depth here.

Issue validation

  • [ X ] I checked for duplicate issues.
  • [ X ] I checked for already existing discussions.
  • [ X ] I checked for an already existing pull request addressing the issue.

I can't find anything related to this issue.

Edited for Better Formatting

Compleur avatar Jan 26 '25 15:01 Compleur