How can I "open" a file from WSL with the default application?
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: RPG Blues Looping
--
Chapters
00:00 How Can I &Quot;Open&Quot; A File From Wsl With The Default Application?
00:30 Answer 1 Score 46
00:40 Answer 2 Score 8
01:35 Answer 3 Score 6
01:44 Answer 4 Score 7
01:57 Thank you
--
Full question
https://superuser.com/questions/1160419/...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows10 #windowssubsystemforlinux
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: RPG Blues Looping
--
Chapters
00:00 How Can I &Quot;Open&Quot; A File From Wsl With The Default Application?
00:30 Answer 1 Score 46
00:40 Answer 2 Score 8
01:35 Answer 3 Score 6
01:44 Answer 4 Score 7
01:57 Thank you
--
Full question
https://superuser.com/questions/1160419/...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#windows10 #windowssubsystemforlinux
#avk47
ANSWER 1
Score 46
Since the Windows Linux interop started working you can now call:
cmd.exe /C start <file>
ANSWER 2
Score 8
As Martijn noted this is the correct way to execute/open a Windows application/file.
cmd.exe /C start <file>
I found it very useful to work this into a bash script that I keep in a folder that is in my system path. I name it start
and do chmod 0744
to the file to make it executable. The $*
means it will pass all of the command line arguments you provided to the script to cmd.exe
.
#!/bin/bash
cmd.exe /c start "Launching from BASH" "$*"
With this command in my system path I can commands like this in Linux that open in Windows:
start FileXYZ.pdf
// Opens the PDF in the default assigned PDF viewer in Windowsstart explorer .
// Opens current WSL folder in the Windows Explorerstart MyApp.exe
// Launches the Windows application
ANSWER 3
Score 7
to expand on Martijn's answer, you can put
alias start='cmd.exe /C start'
in your .bashrc to get expected windows behavior, eg start .
opens explorer in current dir.
ANSWER 4
Score 6
This worked much better for me:
explorer.exe `wslpath -aw <path>`