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.
相关问题
- Inheritance impossible in Windows Runtime Componen
- Pass custom debug information to Microsoft bot fra
- how to get running process information in java?
- Is TWebBrowser dependant on IE version?
- How can I have a python script safely exit itself?
相关文章
- 在vscode如何用code runner打开独立的控制台窗口,以及设置好调试模式时窗口的编码?
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Bundling the Windows Mono runtime with an applicat
- Windows 8.1 How to fix this obsolete code?
- How do I get to see DbgPrint output from my kernel
- CosmosDB emulator can't start since port is al
or, open a cmd window, then call the batch from there, the output will be on the screen.
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.
rem out the @ECHO OFF and call your batch file redirectin ALL output to a log file..
c:> yourbatch.bat (optional parameters) > yourlogfile.txt 2>&1
found at http://www.robvanderwoude.com/battech_debugging.php
IT WORKS!! don't forget the 2>&1...
WIZ
Or.... Call your main .bat file from another .bat file and output the result to a result file i.e.
runner.bat > mainresults.txt
Where runner.bat calls the main .bat file
You should see all the actions performed in the main .bat file now
I found 'running steps' (win32) software doing exactly what I was looking for: http://www.steppingsoftware.com/
You can load a bat file, place breakpoints / start stepping through it while seeing the output and environment variables.
The evaluation version only allows to step through 50 lines... Does anyone have a free alternative with similar functionality?
I don't know of anyway to step through the execution of a .bat file but you can use
echo
andpause
to help with debugging.Source: Batch File Help
@workmad3: answer has more good tips for working with the
echo
command.Another helpful resource... DDB: DOS Batch File Tips