Quickly find bugs in batch scripts – BatDBug by KVC
In CMD, it is difficult to find bugs in a Batch script. The command line only tells us if there is an error in the program, but not where the error in the program is, making it difficult to fix. To solve this problem, Karanveer Chouhan (Kvc) has created the BatDBug plugin. This plugin can help you quickly find bugs in your CMD programs. It saves time by telling you at which line the error resides. You can download this plugin from our Github.
RELATED VIDEO
SYNTAX
The syntax of this plugin is very simple. You just have to call the BatDBug plugin with the name of the file you want to debug.
Call BatDBug [File]
Where file can be substituted for:
ver
: Displays version of the programhelp
: Displays help for the programFile
: File to debug
Example: call BatDBug "MyBatchFile.bat"
DEMONSTRATION
To demonstrate this plugin, l have used a simple batch program to find the greater of two numbers. As you can see in the code below, I have not used the parenthesis in the IF block of code. This is a syntax error in batch.
@echo off
SetLocal EnableDelayedExpansion
Set _A=30
set _B=20
IF %_A% GTR !_B!
Echo "A is greater"
else (
Echo "B is greater"
)
pause > nu
Goto :EOF
Now if you try to run the above code in CMD, it will tell you that the syntax is incorrect, as shown below. To correct this error, you have to check every line for syntax errors, since CMD doesn’t tell us where the error has occurred.

This is where BatDBug makes the difference. If you run the same batch program with BatDBug in CMD, it will tell you not only if there is an error or not, but also which line the error resides in. This saves a lot of user time in debugging the programs. Below is how the BatDBug plugin will show the error in a program. BatDBug runs the program one line at a time, while also checking for errors/bugs at the same time.

If you run a batch program after removing the error in the program, it will run while checking for errors in one line at a time. If no errors are found, it will execute the program displaying the output of the code. Below is how BatDBug will execute the above Batch program, if it has no errors in it.

CONCLUSION
As you can see, the BatDBug plugin can help you in debugging batch programs faster, saving you a lot of time. Kvc has created this awesome plugin that will be very useful to many batch users. For more plugins like this visit our site at Batch-man, you can also join our Discord and YouTube community. Thank you for reading this article. If you have any comments or suggestions, feel free to leave them below.