Is there a way to step through a .bat script? The thing is, I have a build script , which calls a lot of other scripts, and I would like to see what is the order in which they are called, so that I may know where exactly I have to go about and add my modifications.
By adding pause command: One way to debug batch file is by executing the pause command or operation and halting the executing program if any kind of error is found or occurred then a developer can easily fix the issue by restarting the process.
You will be fine as long as you modify the batch file after the current executing line position byte offset at the end of the most recently parsed line of code. If you modify it before then it will start doing strange things (repeating commands etc..).
I don't know of anyway to step through the execution of a .bat file but you can use echo
and pause
to help with debugging.
ECHO
Will echo a message in the batch file. Such as ECHO Hello World will print Hello World on the screen when executed. However, without @ECHO OFF at the beginning of the batch file you'll also get "ECHO Hello World" and "Hello World." Finally, if you'd just like to create a blank line, type ECHO. adding the period at the end creates an empty line.PAUSE
Prompt the user to press any key to continue.
Source: Batch File Help
@workmad3: answer has more good tips for working with the echo
command.
Another helpful resource... DDB: DOS Batch File Tips
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