The
/C switch tells Choice that the valid options are D, C, or E instead of the default Y or N. Because
the text specifically defines the characters that the batch file expects, the batch file uses the /N
switch to suppress displaying the valid key choices on the command line. The /T command line
switch tells Choice to automatically choose E after 10 seconds. The /D command line switch provides
the default choice of E. Finally, the /M command line switch provides the message displayed
to the user.
Although this batch file doesn??™t actually do anything with a file, it shows how you??™d set up the
batch file to process the user choice. Notice that the batch file uses the ErrorLevel clause of the If
statement to detect the user choice. The ErrorLevel clause detects every choice lower than the user
selection, so you must place the values in reverse order, as shown. In addition, you must specifically
138 CHAPTER 5 CREATING CMD AND BAT FILES
set the batch file to go to another location because it will process all other statements after the
current error level.
The processing code simply displays a string telling you what choice the user made.
Pages:
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374