Let's say we execute a command as below and redirect the console output into text file.
My issue is that there is pause
commands within the batch script and when redirecting like this, I cannot know when to hit enter to continue the batch.
Please help me to get the batch "ignores" the pause
commands without changing the batch itself. I prefer to get some redirect/pipe syntax.
MyBatchScriptWithPause.bat > SomeFile.txt
This should do it:
(echo.&echo.&echo.&echo.) | MyBatchScriptWithPause.bat > somefile.txt
assuming that no other command is expecting user input in that batch file.
Edit
It also assumes that only a single pause
command is in that file. Otherwise Andriy's suggestion should work.
MyBatchScriptWithPause.bat > SomeFile.txt < nul
nul
is a DOS device that will provide infinite null data, so it will act as input whenever the script needs some. It is still available even on modern Windows versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With