Prev | Current Page 379 | Next

John Paul Mueller

"Administering Windows Server 2008 Server Core"

The operation results
in an error that you can trap using the ErrorLevel statement when the file doesn??™t exist. When the
ErrorLevel value matches the value you provide, then the If statement executes the command. In
this case, because the code uses the Not clause, the reverse is true, the If statement only executes
the Goto command when the error level is not 1. Notice that, in this case, the code uses the Echo
CREATING BATCH FILES 145
command to display an error message to the user??”Echo works not only for turning messages on
or off, but for displaying custom messages to the user that the Echo setting doesn??™t hide as well.
Once the code performs these initial steps, it determines whether the MyFile.TXT file does exist
using the Exit clause of the If statement. When the file exists, the code immediately begins processing
it. Otherwise, the code displays a message prompting the user to type information for such
a file. Notice the Pause command, which pauses the batch file execution until the user presses a key.
The Copy command sends whatever the user types at the console (CON) to the MyFile.TXT file until
it detects an end of file character, which the user creates by pressing Ctrl+Z.


Pages:
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
gadżety reklamowe teksty piosenek wczasy ciekawe zdania poker online