Whenever you START a new cmd.exe process, it establishes its own IO streams. But for some unknown reason, it also locks any redirect files that may exist in the parent process.
Here is a simple TEST.BAT that demonstrates. It STARTs a new cmd.exe process, and then pauses both processes. The PAUSE output appears on the new console screen, so we know it is not inheriting the IO streams of the main process.
Code: Select all
@echo off
cls
echo begin >LOG1.TXT
echo begin >LOG2.TXT
3>>LOG2.TXT >>LOG1.TXT (
echo before start
echo before start >&3
start "" cmd /c "pause"
echo after start
echo after start >&3
pause >con
)
:: Both of the followng redirections fail if the STARTed process is still active
echo end >>LOG1.TXT
echo end >>LOG2.TXT
If the main process is allowed to continue while the STARTed process is still paused, then the two redirections at the end fail



The main process has no problem writing to the already opened log files within the redirected block. But the two redirections at the end fail to reopen the log files.
What the hell is START doing


Dave Benham