Prev | Current Page 394 | Next

John Paul Mueller

"Administering Windows Server 2008 Server Core"


@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.
:GetFile
IF DEFINED DEBUG @ECHO Adding %1 to the list.
Dir %1 /B /S >> DeleteMe.TXT
Goto :EOF
REM You would normally place the next step of the processing
REM task here.
:NextStep
REM Always remember to remove additional debugging levels.
IF DEFINED DEBUG2 SET DEBUG=
@ECHO ON
The two levels of debugging for this example are DEBUG and DEBUG2. When you define the
DEBUG2 level, the batch file automatically defines DEBUG for you and then removes the DEBUG
definition when the batch file ends. As shown in the code, the DEBUG2 level displays all of the
batch code as it executes. Although this display can be handy, as shown in Figure 5.5, it can also
become quite messy. You don??™t always need it to locate a problem in your batch file. In fact, displaying
the code can sometimes hide problems in plain sight.
Figure 5.4
Batch files can output
as little or much
debugging information
as needed.
152 CHAPTER 5 CREATING CMD AND BAT FILES
Figure 5.5
Display code statements
in batch files
with care to avoid
overwhelming yourself
with too much
content.


Pages:
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406
tanie noclegi mielno asus netbooki Chirurg łódź Namioty Mazury i interesująca cena Szkoły policealne fryzjer w warszawie