Skip to content

Fix Start-Process to handle shell: URIs on Windows#27032

Open
evalentini wants to merge 2 commits intoPowerShell:masterfrom
evalentini:fix-shell-uri-25397
Open

Fix Start-Process to handle shell: URIs on Windows#27032
evalentini wants to merge 2 commits intoPowerShell:masterfrom
evalentini:fix-shell-uri-25397

Conversation

@evalentini
Copy link

PR Summary

Fix Start-Process to handle Windows shell: URIs by detecting the shell: prefix and bypassing CommandDiscovery lookup. Instead pass the URI directly to ShellExecute.

Fixes #25397

PR Context

Problem

On Windows, Start-Process fails when given shell: URIs with a \ like shell:::{8E908FC9-BECC-40f6-915B-F4CA0E70D03D}\Advanced. The root cause is in CommandSearcher.CanDoPathLookup(). When the command contains a backslash, it returns DirectorySeparator, which triggers a code path in setupPathSearcher() that calls ResolvePSPath() → GetNextLiteralPathThatExists() → LocationGlobber.GetProviderPath(). This parses the shell: prefix as a PowerShell provider name and throws ProviderNotFoundException. Without the backslash (shell:::{GUID}), the command takes a different code path and works.

Solution

Add a check in StartProcessCommand.BeginProcessing() to detect shell: URIs on Windows and skip the CommandDiscovery lookup. Instead pass the URI directly to ShellExecute. Cmldet Working Group recommends this solution.

Add test case in "Bug fixes" block to verify shell: URIs don't throw ProviderNotFoundException.

PR Checklist

@evalentini evalentini requested a review from a team as a code owner March 15, 2026 19:13
@evalentini
Copy link
Author

@microsoft-github-policy-service agree

@kilasuit kilasuit moved this to In-Progress-PullRequests in Cmdlets Working Group Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WG-Cmdlets general cmdlet issues

Projects

Status: In-Progress-PullRequests

Development

Successfully merging this pull request may close these issues.

Start-Process prevents use of shell:URIs followed by :: if followed by a path, due to misinterpretation as a provider name.

2 participants