With the following MWE:
\documentclass{article}
\usepackage{filecontents,hyperref,listings}
\begin{filecontents*}{script.bat}
@echo off
echo "Hello, World!"
pause
\end{filecontents*}
\begin{document}
\lstinputlisting[language=csh,float,caption={A Windows batch file}]{script.bat}
Click \href{run:script.bat}{here} to run the script.
\end{document}
I always receive the error
ERROR: I can't write on file `script.bat'.--- TeX said --- <to be read again> \relax l.4 \begin{filecontents*}{script.bat}
In interactive mode (pdflatex test), this error continues until a filename is given which does not have that 'bat' extension. What's going on here?
.com,.dll, etc too in Windows! – Jagath Jul 25 '13 at 12:53.batto.txt. I'm not sure you can make this possible without severely compromising the security of your windows machine. – Mythio Jul 25 '13 at 13:05\begin{filecontents*}{script.txt}and after\end{filecontents*}, in next line give\immediate\write18{mv script.txt script.bat}. This will work. Of course, you need to enable--shell-escape. I tested and this works. – Jagath Jul 25 '13 at 13:10filecontents;-) (I also don't think Cygwin is a requirement; the appropriate DOS command isRENorRENAME.) – Sean Allred Jul 25 '13 at 15:04