TL;DR: Microsoft didn't initially make it possible to run Windows Apps.
Cause of error
The messageAs of Insider Preview build 14951, you can run native Windows programs from Bash under Ubuntu under Windows (WSL)
cannot execute binary fileWindows binaries can now be invoked directly from the WSL command line. This gives users the ability to interact with their Windows environment and system in a way that has not been possible. As a quick example, it is now possible for users to run the following commands: Exec format error
This means Bash is convinced that adb$ export PATH=$PATH:/mnt/c/Windows/System32
$ notepad.exe is the wrong type of file for execution
$ ipconfig.
To find out why, try usingexe | grep IPv4 | cut -d: -f2
$ ls -la | findstr.exe foo.txt
$ cmd.exe /c dir
https://msdn.microsoft.com/en-us/commandline/wsl/release_notes#build-14951
-----------------
Cause of error
---
The message
> cannot execute binary file: Exec format error
This means Bash is convinced that adb.exe is the wrong type of file for execution.
To find out why, try using:
file /mnt/c/Android/sdk/platform-tools/adb.exe
For example:
For example:
$ pwd
/mnt/c/Windows/System32
$ ./notepad.exe
bash: ./notepad.exe: cannot execute binary file: Exec format error
$ file notepad.exe
notepad.exe: PE32+ executable (GUI) x86-64, for MS Windows
---
Windows Susbsystem for Linux
---------
Note that Microsoft's [initial objectives for WSL](https://msdn.microsoft.com/en-gb/commandline/wsl/faq) were
> Using Bash, you can run command-line Linux tools and apps.
Note that does not include
- graphical (X11) Linux tools and apps.
- Windows tools and apps.
---
32-bit binaries
--------------
I believe Microsoft's Windows Subsystem for Linux (WSL) currently only supports 64-bit ELF binaries, not 32-bit ELF binaries.
---
Windows binaries
----------------
Also, from [this question](http://stackoverflow.com/q/38920710/477035) it seems WSL *at time of writing this answer* did not support running Windows executables from within Bash.
This is confirmed by [HowtoGeek](http://www.howtogeek.com/265900/everything-you-can-do-with-windows-10s-new-bash-shell/)
> Unfortunately, there’s no way to actually launch a Windows program or run a Windows command from within a Bash script or the Bash shell. However, you can incorporate Bash commands into a Batch script or PowerShell script
---
Why not :-(
----
If you look at [how Microsoft did this]() you can see that `Bash.exe` is a native Windows console-mode app that, I believe, basically acts as a very thin front end that communicates with an **unmodified** `/bin/bash` which does all the actual interpretation and execution of commands.
> WSL ... is primarily comprised of:
> - User mode session manager service that handles the Linux instance life cycle
> - Pico provider drivers (lxss.sys, lxcore.sys) that emulate a Linux kernel by translating Linux syscalls
> - Pico processes that host the **unmodified** user mode Linux (e.g. **/bin/bash**)
>
[![enter image description here][1]][1]
<sup>*\- [WSL Overview](https://blogs.msdn.microsoft.com/wsl/2016/04/22/windows-subsystem-for-linux-overview/)*</sup>
Since an unmodified /bin/bash does not expect to be able to run programs that are not native Linux ["ELF"](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) binaries, it objects to Windows ["PE"](https://en.wikipedia.org/wiki/Portable_Executable) binaries.
I certainly don't want to run down the rabbit hole of running WINE under WSL. I suggest you avoid this idea too.
---
Possible solution
----------
See [project cbwin](https://github.com/xilun/cbwin)
> Launch Windows programs from "Bash on Ubuntu on Windows" (WSL)
> main features:
> - Win32 command line tools in the console, invoked from WSL
> - Win32 command line tools with redirections to WSL (stdin/stdout/stderr to or from pipe/file)
> - suspend/resume propagation (Ctrl-Z suspends the Win32 processes, fg resumes them)
> - exit codes propagation
> - launch "detached" GUI Windows programs (uses start of cmd)
[1]: https://i.sstatic.net/gIdGD.jpg
Windows Susbsystem for Linux
Note that Microsoft's initial objectives for WSL were
Using Bash, you can run command-line Linux tools and apps.
Note that does not include
- graphical (X11) Linux tools and apps.
- Windows tools and apps.
32-bit binaries
I believe Microsoft's Windows Subsystem for Linux (WSL) currently only supports 64-bit ELF binaries, not 32-bit ELF binaries.
Windows binaries
Also, from this question it seems WSL currently does not support running Windows executables from within Bash.
This is confirmed by HowtoGeek
Unfortunately, there’s no way to actually launch a Windows program or run a Windows command from within a Bash script or the Bash shell. However, you can incorporate Bash commands into a Batch script or PowerShell script
Why not :-(
If you look at how Microsoft did this you can see that Bash.exe
is a native Windows console-mode app that, I believe, basically acts as a very thin front end that communicates with an unmodified /bin/bash
which does all the actual interpretation and execution of commands.
WSL ... is primarily comprised of:
- User mode session manager service that handles the Linux instance life cycle
- Pico provider drivers (lxss.sys, lxcore.sys) that emulate a Linux kernel by translating Linux syscalls
- Pico processes that host the unmodified user mode Linux (e.g. /bin/bash)
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/gIdGD.jpg)
- WSL Overview
Since an unmodified /bin/bash does not expect to be able to run programs that are not native Linux "ELF" binaries, it objects to Windows "PE" binaries.
I certainly don't want to run down the rabbit hole of running WINE under WSL. I suggest you avoid this idea too.
Possible solution
See project cbwin
Launch Windows programs from "Bash on Ubuntu on Windows" (WSL)
main features:
- Win32 command line tools in the console, invoked from WSL
- Win32 command line tools with redirections to WSL (stdin/stdout/stderr to or from pipe/file)
- suspend/resume propagation (Ctrl-Z suspends the Win32 processes, fg resumes them)
- exit codes propagation
- launch "detached" GUI Windows programs (uses start of cmd)