PowerShell / PowerShell/PowerShell

`explorer.exe` should be added to the list of executables to apply legacy argument passing to when `$PSNativeCommandArgumentPassing` is set to `Windows`

Open
#26,437 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Enhancement Needs-Triage WG-Engine WG-NeedsReview
Dominant language
C#
Stars
55.5k
Forks
8.5k
Avg merge
1d 2h
Merged PRs (30d)
88

Description

Summary of the new feature / enhancement

When explorer.exe is passed a double-quoted path whose value ends in \, it (mistakenly) expects the closing \" sequence not to be escaped as \\" (the latter escaping now (sensibly) happens by default, whereas the unescaped form is what Windows PowerShell (mistakenly) passes).

That is, for instance, explorer.exe 'C:\Program Files\' currently quietly fails (notably, this form, with a trailing \, is created by tab-completion) with Windows as the $PSNativeCommandArgumentPassing mode (which is the default on Windows): the path isn't recognized and File Explorer defaults to the Documents folder.
For background information, see https://github.com/PowerShell/PowerShell/issues/26422#issuecomment-3517902966

Proposed technical implementation details (optional)

Add explorer to the list of processes at https://github.com/PowerShell/PowerShell/blob/4aa65a77be93911072e015f2a52656786c8f54bf/src/System.Management.Automation/engine/NativeCommandProcessor.cs#L215 so as to make it exhibit the same (broken) behavior as Windows PowerShell by default, to match explorer.exe's own broken behavior.

Note: A prerequisite for this implementation to take effect is fixing the following issue:

  • #26432

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read src/System.Management.Automation/engine/NativeCommandProcessor.cs around line 215 and review prerequisite issue #26432 first. Confirm how the executable list is used for Windows argument passing, then verify that explorer.exe is covered by the requested legacy handling once the prerequisite is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
cli, operating-systems
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.