These are the two reasons that most administrators
I??™ve talked with give for using batch files instead of scripts. Although batch files can??™t replace
scripts or full-fledged programming languages, over the years I??™ve found that batch files serve the purpose
for most administrator needs.
150 CHAPTER 5 CREATING CMD AND BAT FILES
You can extend debugging to other activities. For example, you might want to know the current
value of a variable within the batch file. Because you don??™t have a debugging environment that you
can rely on to perform such tasks, you??™ll need to use other methods with a batch file. Listing 5.3
shows one technique you can use to extend a batch file to output debugging information about an
internal variable (note that this example also uses the DEBUG environment variable). You can obtain
this example on the Sybex Web site at http://www.sybex.com/WileyCDA/.
Listing 5.3: Adding Simple Debugging to a Batch File
@ECHO OFF
REM Locate all of the temporary files on your hard drive.
@ECHO Locating temporary files to delete.
FOR /F %%F IN (DelFiles.TXT) DO CALL :GetFile %%F
GOTO :NextStep
REM This is the actual code for handling the temporary file
REM processing.
Pages:
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403