在 WSL 中通过 xdg-open 打开 Windows 原生 exe 程序

nep*_*tom 2 ubuntu xdgutils windows-subsystem-for-linux

在 Linux 中使用时man,许多命令都会列出 URL,这些 URL 在某些终端中类似于gnome-terminalterminator可单击。

例如,man ls显示:

鼠标悬停时可点击的 URL

允许单击http://www.gnu.org/software/coreutils

在 WSL 下的Gnome 终结者中单击它会使其挂起。
并在启动 terminator 的终端中显示此输出:

etomort@ES-00002604:/mnt/c/Users/etomort
$ /usr/bin/xdg-open: 782: /usr/bin/xdg-open: : Permission denied
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: x-www-browser: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: firefox: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: iceweasel: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: seamonkey: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: mozilla: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: epiphany: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: konqueror: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium-browser: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: google-chrome: not found


[1]+  Stopped                 terminator  (wd: ~)
(wd now: /mnt/c/Users/etomort)
[2]   Done                    terminator
Run Code Online (Sandbox Code Playgroud)

有没有办法xdg-open在WSL中调用Windows exe程序?

注意:这个问题是相关的,但更具体。
唯一的答案对此没有用。

小智 6

我在 WSL 中的 Hashicorp Vault 中遇到了同样的问题。

xdg-open我创建了一个基本上转发到的脚本powershell -c start

虽然没有经过太多测试。

sudo tee /usr/local/bin/xdg-open <<EOF
#!/bin/sh

powershell.exe -c start "'\$@'"
EOF
sudo chmod +x /usr/local/bin/xdg-open
Run Code Online (Sandbox Code Playgroud)

奥利弗干杯