dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.13k stars 4.7k forks source link

Process.Start opens explorer itself instead of URL #108817

Open jk-85 opened 5 days ago

jk-85 commented 5 days ago

Description

I tested it up to .Net 8 and with Win7 and Win10:

System.Diagnostics.Process.Start("explorer.exe", "https://www.dextools.io/app/en/solana/pair-explorer/FqfttpudzsmLbnx6jR5FBpqJCJxQuvT8tAS2ma68HHQe?t=1724604221437");

This should open the default web-browser and it does work fine with all other urls, but when I use this url, the standard explorer.exe will be opened and no webbrowser starts. When I delete the part "?t=1724604221437" the web-browser will start as expected and appends a "?t=xxxxxxxx" number on it's own.

Maybe it's more related to explorer.exe instead of the Process-class.

Reproduction Steps

See above

Expected behavior

See above

Actual behavior

See above

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

dotnet-policy-service[bot] commented 5 days ago

Tagging subscribers to this area: @dotnet/area-system-diagnostics-process See info in area-owners.md if you want to be subscribed.

am11 commented 5 days ago

This is a limitation of cmd.exe/explorer.exe, not .NET. A better approach is using rundll32 with url.dll, which correctly handles URLs with query strings:

System.Diagnostics.Process.Start("rundll32", 
    "url.dll,FileProtocolHandler https://www.dextools.io/app/en/solana/pair-explorer/FqfttpudzsmLbnx6jR5FBpqJCJxQuvT8tAS2ma68HHQe?t=1724604221437");

This opens the browser with the full URL. See this discussion.

jk-85 commented 2 days ago

Thanks for the reply!