Term of the Moment

dumpster diving


Look Up Another Term


Definition: Choice


A Windows command that allows a batch file to include multiple tasks and lets the user choose which one to perform. Choice accepts a single character as input. The syntax varies between Windows versions; however, the following three-character example works in Windows Vista, 7 and 8. See batch file abc's.

  @echo off
  choice /c abc
  if errorlevel 3 goto thingc
  if errorlevel 2 goto thingb
  (do thing a here)
  goto end

  :thingb
  (do thing b here)
  goto end

  :thingc
  (do thing c here)
  :end


The allowable characters follow the /c, and the example above prompts the user with [A, B, C]?. If any other character is entered, the computer beeps. The input character is stored as an error level: "a" becomes error level 1; "b" is 2 and "c" is 3.