Along with Windows 10 Anniversary update for summer 2016, came the possibility to run ubuntu binaries inside the new Windows Subsystem for Linux (WSL), a "lightweight" virtualized subsystem.
On 19 Oct 2016, Microsfot announced the plans for the official solution, which is based on the almost forgotten binfmt_msc Linux facility for launching binaries. The registration command for the binfmt_misc would like this (where
/init is the provisional binfmt_misc "interpreter" for the win-executables):
sudo echo ":WSLInterop:M::MZ::/init:" > /proc/sys/fs/binfmt_misc/register
And then win-executable would be launched like regular programs:
$ export PATH=$PATH:/mnt/c/Windows/System32 $ notepad.exe $ ipconfig.exe | grep IPv4 | cut -d: -f2 $ ls -la | findstr.exe foo.txt $ cmd.exe /c dir
Not that any win-executable must reside in the windows (DrvFs) file-system - not on the Linux's file-system (VolFs) - in order to inherit a proper Windows working-directory.
Untill you get the latest build, project cbwin offers a workaround, by installing 3 new linux commands inside WSL:
wcmd: call a win-executable through
wrun: call a win-executable synchronously with
CreateProcess, and wait to die (not using
wstart: launch a detached (asynchronously) command (with the use of
In order to use them, you must:
outbash.exewill be installed in your regular Windows filesystem (somewhere in your
outbash.exe(wherever you installed it) to start WSL, NOT
Tip: If the executable launched with
wrun spawns any children, these survive only for as long that executable remains alive.
In other words, trying to start
wcmd won't work, because notepad will be killed just after having been launched -- Use
wrun (synchronously) or
wstart (asynchronously) in this case.