Use bash.exe to run bash scripts in Windows

September 1, 2021windowswslbash

If you have the Windows Subsystem for Linux (WSL) installed then you can use wsl.exe to start any linux distribution you have installed from the command prompt. What I recently learned about though is that there is a bash.exe as well which can be used to execute a bash script directly.

bash -li -c "./myscript.sh"

The -li flag starts the bash instance as a login shell and the -c flag is the command to execute. In this case, execute our script directly.