

Looking at the above file the developer can fix the program and execute again. More help is available by typing NET HELPMSG 3506. The file testerrors.txt will display the error messages as shown below: Let us log the message and see what we get.Įxecute the following command in your command line:Ĭ:\>test.bat > testlog.txt 2> testerrors.txt Here is an example, consider the following test.bat file: Another easy way out is to log those messages in another file and view it step by step to understand what went wrong. It might get hard to debug the error just looking at a bunch of echo displayed on the command prompt. Logging the error messages to another file In the example below, the batch script is paused as the input value is mandatory and not provided.

When the script is paused, the developer can fix the issue and restart the processing.

offĪnother way is to pause the batch execution when there is an error. For example, if the input given is a negative number, less than 2, etc. Similarly, the echo command can be used in place when you think that the error can happen. The echo command is used to display the result and also if the input is not given. Here is a simple example that displays even numbers based on the input given. It will display the message in the command prompt and help you debug where things have gone wrong. Using echo commandĪ very simple debug option is to make use of echo command in your batch script wherever possible. Debugging a batch script becomes important when you are working on a big complex batch script.įollowing are the ways in which you can debug the batch file.
