Prev | Current Page 392 | Next

John Paul Mueller

"Administering Windows Server 2008 Server Core"


: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
@ECHO ON
This is actually a batch file within a batch file. The code begins by displaying information to the
user that it??™s collecting a list of temporary files. At this point, the user normally waits while the
batch file does its job in complete silence. However, as a developer, you really need to know what??™s
going on within the batch file. To make this work, you need to execute multiple commands. Consequently,
the batch file calls a label named :GetFile and passes it to the %%F argument.
Now, look at the :GetFile label and you??™ll see two statements. The first displays the current %%F
value when you create an environment variable named DEBUG. However, notice that it??™s called %1
here, not %%F. Whenever you employ a Call command to pass control to a label within a batch file,
you create a new batch file context. As far as the :GetFile label is concerned, it exists in a different
batch file from the original that called it. The first batch file passes %%F as an input value, so it
appears as %1 to the :GetFile label code.


Pages:
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404