How can I "open" a file from WSL with the default application?
-------------------------------------------------------------------------------
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
-------------------------------------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: The World Wide Mind
--
Chapters
00:00 Question
00:39 Accepted answer (Score 74)
01:09 Answer 2 (Score 45)
01:23 Answer 3 (Score 9)
02:32 Answer 4 (Score 8)
02:55 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
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
-------------------------------------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: The World Wide Mind
--
Chapters
00:00 Question
00:39 Accepted answer (Score 74)
01:09 Answer 2 (Score 45)
01:23 Answer 3 (Score 9)
02:32 Answer 4 (Score 8)
02:55 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>`