Roman Marynchak <roman.marynchak@...> writes:
> I have strange problems with launching bat scripts on Windows. The
> idea is to use cmd.exe and a bat file as an argument. During the
> process of rewriting the elegant solutions into the stupid ones, I
> found that even this all-hardcoded variant is not working:
> (sb-ext:run-program "C:/Windows/System32/cmd.exe" '("/c"
If you don't specify input and output, standard channels (in/out/error)
in the child process are redirected to NUL. If the effect that you're
expecting is an output from e.g.
@echo "Hello world"
then specify :output t :error output.
I recommend trying a batch file containing the command
echo "See how I run" >>"%~f0.out"
This command, being executed inside .../file.bat, will add a text line
to .../file.bat.out, independently of any standard channel
redirections. It's easy to check if your file is running. A script
containing "notepad.exe" is good for debugging too: if it's running,
visual indication is available immediately :)
Furthermore, if your batch file extension is present in your %PathExt%
variable (like .BAT and .CMD do by default), there is no need to start
cmd.exe explicitly. The latter may make things worse in a number of
ways; unexpected "terminate batch job [y/n]?" query on Ctrl+C is one of
As of Win64 fork: on the most recent version
(22.214.171.124.288.wth.kovalenko), I've just tested several batch files with
several variations of RUN-PROGRAM parameters. No problems were observed
as long as redirection is trivial (no std channels, or all channels
inherited, or some of them redirected to compatible FD streams).
Non-trivial redirections (e.g. output to string stream or Gray stream)
have some known problems (two different sets of problems for my fork and
for the upstream SBCL). When I migrated to "fds are handles" model, I
had to start using CreateProcess instead of MSVCRT _spawn; also, I had
to modify some code that manages pipe creation and channel inheritance.
Though I'm trying to avoid incompatibilities, be prepared to get
different results from upstream SBCL and mine. RUN-PROGRAM is one of the
areas I'm currently working on, so i'll be glad to receive related bug
> It executes without problems, but run.bat does nothing (or cmd does
> not run it at all). I have tried both SBCL 1.0.48 and Win64 fork.
> Can something better be done here? I will appreciate any advices.
Regards, Anton Kovalenko
+7(916)345-34-02 | Elektrostal' MO, Russia