Prev | Current Page 378 | Next

John Paul Mueller

"Administering Windows Server 2008 Server Core"

TXT Contains:
Type MyFile.TXT
Goto TheEnd
REM Determine whether the user wants to delete the file.
:Process2
If Not %1==delete Goto ProcessError
Erase MyFile.TXT
Echo Deleted MyFile.TXT
Goto TheEnd
REM The user didn??™t define a processing action.
:ProcessError
Echo You didn??™t tell the batch file what to do!
Echo Type UseIf Display to display the file or
Echo UseIf Delete to delete the file.
:TheEnd
Echo On
The first line of this example demonstrates a principle that you should always use in batch files
that you expect someone else will use??”check for errors within the limits of the batch file to do so.
In this case, the batch file expects the user to provide an input value of delete or display. When
the user doesn??™t provide any input value, then the first input value, %1, is blank so the string Err
equals Err and the code goes to a label named ProcessError. Batch files can work with up to nine
input values at a time using %1 through %9 as variables. The Goto statement always tells the code
to go to a label within the batch file. You define a label by preceding the label name with a colon
such as :ProcessError.
The next segment of code attempts to copy a temporary file to another file.


Pages:
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
teksty piosenek spolszczenia poker online Poker Porady bukmacher