Question: Windows 7. Emacs 24.3.1. Git 1.8.1.msysgit.1. I have the following in my equivalent .emacs file:

```
(if (equal system-type 'windows-nt)
    (progn (setq explicit-shell-file-name
                 "C:/Program Files (x86)/Git/bin/sh.exe")
           (setq shell-file-name "bash")
           (setq explicit-sh.exe-args '("--login" "-i"))
           (setenv "SHELL" shell-file-name)
           (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)))

```

This works great when I want to do *M-x shell*: I can pop open a shell and type "ls".

However, *M-x shell-command* is failing. When I try to run "ls" via shell-command (which should print its output in the \*Shell Command Output\* buffer, according to *C-h f shell-command*), I get a single error message:

"Searching for program: permission denied, bash"

There are some very old suggestions on the Google about *call-process* and many questions on StackOverflow about getting the shell to work in Emacs. Please note that *M-x shell* works great, and what I'd like to work is shell-command.

(Reason: <https://github.com/donkirkby/live-py-plugin#installing-the-emacs-mode>)

Answer: 
Try setting both variables to point to the same executable and make sure the path is in `exec-path`:

```
(setq explicit-shell-file-name
      "C:/Program Files (x86)/Git/bin/bash.exe")
(setq shell-file-name explicit-shell-file-name)
(add-to-list 'exec-path "C:/Program Files (x86)/Git/bin")

```
Using GitBash you can use the lein script instead of the lein.bat script. Put the lein script into a directory called `bin` in your user account on windows. GitBash should have that `bin` directory on its executable `PATH`, so you can run `lein` anywhere.

With this approach you do not need any configuration in Emacs Lisp.

[See my full answer](https://stackoverflow.com/questions/39761234/git-bash-for-windows-not-working-lein-repl-command/49917321#49917321)