Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Just wondering...

BATCH_DEBUGGING is an environment variable that is created once you start debugging a batch file.
It is equal to 1 when debugging a batch file.
It exists only when debugging a batch file.

_BDEBUGGER is an internal variable that is equal to 1 when debugging a batch file.
It is equal to 0 otherwise.

Example:
Code:
@setlocal
@echo off
if defined BATCH_DEBUGGING echo BATCH_DEBUGGING exists in the environment.
if %BATCH_DEBUGGING eq 1 echo BATCH_DEBUGGING equals 1. You are debugging a batch file.
if %_BDEBUGGER eq 1 echo _BDEBUGGER equals %_BDEBUGGER. You are debugging a batch file.
endlocal
quit

Of course, if you create these yourself, and define these with different values, you get different results;
Code:
@setlocal
@echo off
set BATCH_DEBUGGING=abc
if defined BATCH_DEBUGGING echo BATCH_DEBUGGING exists in the environment.
if %BATCH_DEBUGGING eq 1 echo BATCH_DEBUGGING equals 1. You are debugging a batch file.
set _BDEBUGGER=9
if %_BDEBUGGER eq 1 echo _BDEBUGGER equals %_BDEBUGGER. You are debugging a batch file.
endlocal
quit

Thus, best never to over-ride BATCH_DEBUGGING and/or _BDEBUGGER in your .BTM files.

Joe
 
Excellent advice, Joe.
Thank you for your time and effort.

Am I the only one who wonders why we have two of these variables? I believe BATCH_DEBUGGING is a recent addition. Whatever the case, when we had the one why did we need the other?
 
At a guess, the environment variable is for the benefit of CMD‍.EXE scripts.
 
Well, I thought it had to be something like that, and it's not all that important, but couldn't BDEBUGGER produce BATCH_DEBUGGING when debugging a BAT file and refrain from doing so when debugging a BTM file?
 
Back
Top