How can I debug a .BAT script?

后端 未结 11 1311
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 09:42

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 th

11条回答
  •  佛祖请我去吃肉
    2020-11-28 10:08

    Make sure there are no 'echo off' statements in the scripts and call 'echo on' after calling each script to reset any you have missed.

    The reason is that if echo is left on, then the command interpreter will output each command (after parameter processing) before executing it. Makes it look really bad for using in production, but very useful for debugging purposes as you can see where output has gone wrong.

    Also, make sure you are checking the ErrorLevels set by the called batch scripts and programs. Remember that there are 2 different methods used in .bat files for this. If you called a program, the Error level is in %ERRORLEVEL%, while from batch files the error level is returned in the ErrorLevel variable and doesn't need %'s around it.

提交回复
热议问题