Microsoft KB Archive/68969

Branching on Programs Without Errorlevels PSS ID Number: Q68969 Article last modified on 02-05-1993 PSS database name: O_MSDOS

3.30 4.01

MS-DOS

Summary:

The following procedure can be used to allow conditional branching in batch files for programs that do not return errorlevels but do return text information (for example, PRINT.COM). Actual implementation will vary depending on what information is returned.

More Information:

Create a text file in the following manner:

C:>COPY CON C:\PART1 SET BOOL=^Z It is essential to enter the CTRL+Z BEFORE pressing ENTER.

Create a batch file which will use the output of the program to set the environment variable “BOOL” to a value. “BOOL” can then be used to branch as needed. This example branches depending on the number of files in PRINT’s print queue.

ECHO OFF DEL C:\PART2.BAT COPY C:\PART1 C:\PART2.BAT PRINT | FIND /C &quot;PRINT queue&quot; >> c:\PART2.BAT CALL C:\PART2.BAT DEL C:\PART2.BAT IF %BOOL%.==1. ECHO print queue is empty IF %BOOL%.==0. ECHO print queue is not empty Additional reference words: 3.30 4.01 noupd

Copyright Microsoft Corporation 1993.