• Batch File Choice Command (XP Home)

    Author
    Topic
    #431301

    I’ve been trying to use the “choice” batch command, but it seems that it is not available in XP. Also, I must have forgotten all I knew about batch files, as I can’t remember how to implement a simple Y/N conditional function. I would appreciate any help.

    Viewing 1 reply thread
    Author
    Replies
    • #1009311

      Choice is not available in Windows XP indeed. See Microsoft Windows XP – Command-line reference A-Z. There is a section about batch files.

    • #1009315

      You have (at least!) two choices [tee-hee]!

      Either copy CHOICE.EXE from a previous version of Windows into a directory in the standard path (e.g. Windows or WindowsSystem32), and use it like you ued to,
      or investigate the SET /P command, ‘recently’ introduced. Here’s a clunky BATch file to demonstrate:

      @echo off
      :loop
      set /p answer="Reply Y or N to this question  "
      if /i "%answer%"=="Y" echo Chuck said Yes! & goto replyyes
      if /i "%answer%"=="N" echo Chuck said No!  & goto replyno
      goto loop
      
      :replyyes   Here do what you wish for a Y answer
      
      :replyno    Here do what you wish for a N answer

      To find out more, do SET /? and/or IF /? in a Command Prompt window. There are various other BATch file sites on the internet I can point you at, but Hans’ link has more-or-less what you get from the /? commands I suggested!

      John

    Viewing 1 reply thread
    Reply To: Batch File Choice Command (XP Home)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: