How can I "open" a file from WSL with the default application?
Since the Windows Linux interop started working you can now call:
cmd.exe /C start <file>
A recent answer for WSL 2: Just do wslview slides.pdf
.
This is a part of the wslu collection and was pre-installed in my Ubuntu. Unfortunately, the documentation is a bit sparse.
All the cmd.exe
variants didn't work for me, because it doesn't want to open inside a path like \\wsl$\…
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