Welcome!

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

SignUp Now!

Doc nits: HELP BATCHDETECT

Charles Dye

Super Moderator
May
5,005
130
Staff member
Since time immemorial, the help file has offered this advice:

From a batch file, you can determine if <shell> is loaded by testing for the variable function @EVAL, with a test like this:

if "%@eval[2 + 2]%" == "4" echo <shell> is loaded!

This is (a) peculiar syntax in both shells and (b) not foolproof -- @EVAL's return value is affected by SETDOS /F. Also, the "loaded" terminology is a throwback to DOS days. I would suggest instead something like this:

A batch file can test whether it is running in TCC by attempting a numeric comparison:

if 01 == 1 echo Running in TCC!

This syntax is legal in both shells. In TCC this is a numeric comparison and true; in CMD.EXE it is a string comparison and false. Once you have established that the batch file is running in TCC, you can use internal variables like _CMDPROC, _4VER, _DOS, _DOSVER, and _WIN to further determine the operating environment.

You can prevent your batch file from running in CMD.EXE by giving it the .BTM extension. CMD.EXE doesn't recognize .BTM files as batch files.
 

Similar threads

Replies
0
Views
224
Replies
3
Views
2K
Back
Top