-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Determine path of cmd.exe programatically from WSL #5743
Description
Is your feature request related to a problem? Please describe.
Modules like https://www.npmjs.com/package/open are used to, for example, open a URL in a browser. This module has built-in detection for if it is running inside WSL. In which case it will utilize cmd.exe to invoke a browser on the Window side.
This mechanism only works when cmd.exe is available through the $PATH environment variable. This is the default behavior in WSL.
When disabling the attachment of Windows elements to the $PATH environment variable, this entire process no longer works. Disabling the $PATH attachment can be desireable in certain configurations, where you want to ensure that no Windows binaries creep into your environment unintenionally.
Describe the solution you'd like
My idea was some /proc endpoint that would return information about the Windows environment. An equivalent of %SystemDrive% and %SystemRoot% would probably be sufficient.
Describe alternatives you've considered
Reading the base mount point from /etc/wsl.conf, if it exists, then iterating over /<mount_point>/[a-z] and searching for a Windows installation.
This is not feasible. Multiple Windows installations could exist. I'm not sure if exotic configurations are possible where the Windows directory is not named Windows.
A search feels unclean. This information should be accessible through a clear API.
Additional context
sindresorhus/open#186