Tangling creates the batch file, execution of source block tries to execute the source block in the specified language (and there is no ob-bat
I know of).
You can execute the tangled batch file in a shell source block. Therefore add the following to your org file:
#+BEGIN_SRC sh :exports results :results output
cmd /c ""d:\Programs\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" & run_tests.bat"
#+END_SRC
This first runs the batch and then, separated by &
, your batch script.
Note that I have a MinGW environment with a bash shell. If you want to run windows cmd.exe
directly you may find a hint here, which introduces a shcmd
header option.
Also, you need to require ob-sh
or ob-shell
, depending on your org version. Therefore I do:
(unless (require 'ob-sh nil 'noerror)
(require 'ob-shell))
Btw, if all you want is to execute some command sequence you can simply do:
#+BEGIN_SRC sh :exports results :results output
call "d:\Programs\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
echo "insert commands here"
#+END_SRC
EDIT:
Since I may need a windows native execution facility in org-mode I will write an ob-bat.el
as soon as I am back from holiday (next week). Meanwhile you may try this code snippet (since I have no windows box it is untested):
(require 'ob)
(require 'ob-shell)
(defvar org-babel-tangle-lang-exts)
(add-to-list 'org-babel-tangle-lang-exts '("bat" . "bat"))
(defcustom org-babel-bat-command "cmd.exe"
"Name of command to use for executing bat code.")
(defun org-babel-execute:bat (body params)
"Execute a block of bat code with cmd.exe.
This function is called by `org-babel-execute-src-block'."
(let ((shell-file-name org-babel-bat-command))
(org-babel-execute:shell body params)))
(provide 'ob-bat)
With this you should be able to execute bat source blocks:
#+BEGIN_SRC bat :exports results :results output
echo hello
#+END_SRC