Results 1 to 6 of 6
  1. #1
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Batch File Choice Command (XP Home)

    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.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Batch File Choice Command (XP Home)

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

  3. #3
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch File Choice Command (XP Home)

    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:<pre>@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</pre>

    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
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  4. #4
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Batch File Choice Command (XP Home)

    Thanks for the advice. I'll give it a shot.

  5. #5
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Batch File Choice Command (XP Home)

    I'm guessing there are a lot of us who don't know much about the post-DOS 6.2 enhancements. Your post was pretty much all news to me, and potentially handy news at that. Thanks for the clear example.

  6. #6
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,572
    Thanks
    5
    Thanked 1,057 Times in 926 Posts

    Re: Batch File Choice Command (XP Home)

    If you want a glimpse of the future follow some of the links at Monad Search Results. <A target="_blank" HREF="http://www.microsoft.com/technet/technetmag/issues/2005/11/Scripting/default.aspx">Scripting: Monad: The Future of Windows Scripting -- TechNet Magazine, November
    Joe

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •