I got the latest update from Windows that adds bash, and I was trying to script the execution of an Android emulator through this; however the Path variables of Windows are not taken into account for bash.

Plus I tried executing adb manually and I got:

andtest@DESKTOP:/mnt/c/Android/sdk/platform-tools$ exec ./adb.exe
bash: /mnt/c/Android/sdk/platform-tools/adb.exe: cannot execute binary file: Exec format error

Is there something I'm missing here? I want to use this Windows computer as a test server for Android.

  • Can you not just use an absolute bath to call exec, or create an alias?
    – codaamok
    Sep 8, 2016 at 8:41
  • Did you see this posting? stackoverflow.com/questions/10681101/… Sep 8, 2016 at 8:44
  • I may be really wrong, but you can't execute .exe files in bash - even in windows
    – Orphans
    Sep 8, 2016 at 8:44
  • @adampski I get an "exec format error" when I run exec ./adb.exe
    – M Rajoy
    Sep 8, 2016 at 9:02
  • Try it without the .exe extension. Sep 8, 2016 at 9:07

1 Answer 1


TL;DR: Microsoft didn't initially make it possible to run Windows Apps.

As of Insider Preview build 14951, announced 19 October 2016, you can run native Windows programs from Bash under Ubuntu under Windows (WSL)

Windows 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:

$ 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


The announcement said

Windows Subsystem for Linux: Today we are happy to announce two large updates to WSL!

  • Official Ubuntu 16.04 support. Ubuntu 16.04 (Xenial) is installed for all new Bash on Ubuntu on Windows instances starting in build 14951. This replaces Ubuntu 14.04 (Trusty). Existing user instances will not be upgraded automatically. Users on the Windows Insider program can upgrade manually from 14.04 to 16.04 using the do-release-upgrade command.

  • Windows / WSL interoperability. Users can now launch Windows binaries directly from a WSL command prompt. This is the number one request from our users on the WSL User Voice page.

(my emphasis)

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:

$ pwd
$ ./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 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 at time of writing this answer did 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
- 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)
  • Thanks, this also explains why the JAVA_HOME is not valid: all Java binaries are for Windows.
    – M Rajoy
    Sep 8, 2016 at 11:23
  • You could use apt-get install default-jre default-jdk and then you'd be able to use bash to compile .java to byte-code and run it. You should, in principle, be able to run java applications you've compiled under Windows and vice versa. Sep 8, 2016 at 12:46
  • 1
    This is no longer valid. With the latest preview build of windows 10, WSL can execute windows binaries just fine.
    – Dave
    Oct 31, 2016 at 13:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .