如何调试 .BAT 脚本? [英] How can I debug a .BAT script?
问题描述
有没有办法单步执行 .bat 脚本?问题是,我有一个构建脚本,它调用了很多其他脚本,我想看看调用它们的顺序是什么,这样我就可以知道我必须去哪里并添加我的修改.
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.
推荐答案
我不知道如何逐步执行 .bat 文件,但您可以使用 echo
和 暂停
以帮助调试.
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 Hello World 在执行时会在屏幕上打印 Hello World.但是,如果批处理文件的开头没有 @ECHO OFF,您还将获得ECHO Hello World"和Hello World".最后,如果您只想创建一个空行,请键入 ECHO.在末尾添加句点会创建一个空行.
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.
来源:批处理文件帮助
@workmad3:answer 有更多使用 echo
命令的好技巧.
@workmad3: answer has more good tips for working with the echo
command.
另一个有用的资源... DDB:DOS 批处理文件提示
Another helpful resource... DDB: DOS Batch File Tips
这篇关于如何调试 .BAT 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!