Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Yes/No Command?  (Read 8942 times)

0 Members and 1 Guest are viewing this topic.

samanathon

  • Guest
Yes/No Command?
« on: October 18, 2005, 08:51:37 AM »
Sorry if this is a repeat, I tried searching but I don't really know the name of this command!

I was wondering what the syntax is for the "Yes/No" command (is it really a command?). ie: "This will copy %varFileName% to %varLocation%, if you would like to continue press Y, or press N"

That's not exactly how I would write it, but I would like the user to have to check to make sure that %varFileName% is correct, then press Y to continue.

I am currently using the Pause command for this . . .

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Yes/No Command?
« Reply #1 on: October 18, 2005, 04:06:52 PM »
Need more info. What Windows version are you using? WinME and below you can use CHOICE. Win2000 and above you can use SET /P. I have no idea about NT.

Let us know. 8)

CHOICE is not available in Win2000 and XP.
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

samanathon

  • Guest
Re: Yes/No Command?
« Reply #2 on: October 18, 2005, 08:41:37 PM »
I'm on XP machines.

vibhor_agarwalin



    Adviser

    Re: Yes/No Command?
    « Reply #3 on: October 18, 2005, 11:35:36 PM »
    Never heard of the Yes/No command.
    Vibhor Kumar Agarwal

    uli_glueck

    • Guest
    Re: Yes/No Command?
    « Reply #4 on: October 19, 2005, 03:59:51 AM »
    In NT Choice is also not available.
    But it is in the ressource kit. :-)

    vibhor, the op means choice.com.

    uli
    « Last Edit: October 19, 2005, 04:00:22 AM by uli_glueck »

    vibhor_agarwalin



      Adviser

      Re: Yes/No Command?
      « Reply #5 on: October 19, 2005, 04:25:12 AM »
      Op?
      Vibhor Kumar Agarwal

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Yes/No Command?
      « Reply #6 on: October 19, 2005, 04:36:46 AM »
      This little snippet will give you a basic design you can use.

      Code: [Select]

      @echo off
      :start
      set /p var=This will copy %varFileName% to %varLocation%, if you would like to continue press Y, or press N
      if /i %var%=Y goto LabelA
      if /i %var%=N goto LabelB
      goto start

      :LabelA


      :LabelB


      I'm guessing %varFileName% and %varLocation% were generated elsewhere in your batch file.

      Happy Computing. 8)
      « Last Edit: October 19, 2005, 06:12:53 AM by Sidewinder »
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      samanathon

      • Guest
      Re: Yes/No Command?
      « Reply #7 on: October 20, 2005, 06:39:31 PM »
      Well, I tried that without much luck . . .

      Here's my code as of right now:

      Code: [Select]
      @ECHO OFF
      CD\

      REM * * * Change and varify these settings for each client/show! * * *

      set varClient=Lilly
      set varProduct=RoboCDROM
      set varShow=AAO_Chicago
      set varSurvey=092205RuboCDROM

      REM ---------------------------------------------------------

      REM * * * These Variables do not need to be changed * * *

      set varDate=%date:~4,2%%date:~7,2%%date:~12,2%
      set varDCPS=%varDate%_%varClient%_%varProduct%_%varShow%
      set varDesktop="C:\Documents and Settings\%username%\Desktop\%varShow% Leads\%varDate%\%computername%"

      REM ---------------------------------------------------------

      Color 0C

      ECHO.
      ECHO This will back up %varClient%'s %varProduct% data into the "%varShow% Leads" folder on the desktop.
      PAUSE
      ECHO.


      This is where I would like the Yes/No Command, instead of the whole ECHO & PAUSE lines above. If the user presses "Y", then run the lines below. If the user presses "N" then exit.

      Code: [Select]
      Color 0A

      xcopy "c:\Program Files\NewLeads\FAILSAFE" %varDesktop%\FAILSAFE /-y /I
      xcopy "c:\Program Files\NewLeads\%varShow%.mdb" %varDesktop%\ /-y
      xcopy "c:\Program Files\NewLeads\%varShow%.profile" %varDesktop%\ /-y
      xcopy "c:\Program Files\NewLeads\%varSurvey%.SRV" %varDesktop%\ /-y

      ECHO *********************************************************

      ECHO.
      ECHO This will backup the data from %computername% to your Flash Drive.
      ECHO.

      Color 0F

      xcopy "c:\Program Files\NewLeads\FAILSAFE" "\%varShow% Leads\%varDCPS%\%ComputerName%\FAILSAFE" /-y /I
      xcopy "c:\Program Files\NewLeads\%varShow%.mdb" "\%varShow% Leads\%varDCPS%\%ComputerName%\" /-y
      xcopy "c:\Program Files\NewLeads\%varShow%.profile" "\%varShow% Leads\%varDCPS%\%ComputerName%\" /-y
      xcopy "c:\Program Files\NewLeads\%varSurvey%.SRV" "\%varShow% Leads\%varDCPS%\%ComputerName%\" /-y

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Yes/No Command?
      « Reply #8 on: October 21, 2005, 05:40:02 AM »
      There is no Yes/No command built into windows. If you find utilities that do present a yes/no option it's only because the programmer who wrote the code put it into the program.

      You can duplicate it however. Nowhere in your code did I find the set /p command that was suggested.

      Replace the echo/pause sequence in the first box with:
      Code: [Select]

      :redo
      set /p var=Enter Y/N
      if /i %var%=n goto :eof
      if /i %var%=y goto copies
      goto redo
      :copies
      .
      .
      xcopy etc....

      You can change Enter y/n with any literal (including variables) you want. If the user enters N or n the batch file will go to end of job. If the user enters Y or y the batch file will goto :copies which presumably you place just before the XCOPY statements. If the user enters any other characters the batch file will loop back to :redo and present the message again. Feel free to change any part of the logic.

      Hope this helps. 8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      samanathon

      • Guest
      Re: Yes/No Command?
      « Reply #9 on: October 21, 2005, 07:31:29 PM »
      I tried just as you suggested, but no matter what I input (y/n/other), the .bat just exits . . .

      Code: [Select]
      REM ---------------------------------------------------------

      Color 0C

      ECHO.
      ECHO This will back up %varClient%'s %varProduct% data into the "%varShow% Leads" folder on the desktop.
      :redo
      set /p var1=Enter Y/N
      if /i %var1%=n goto :eof
      if /i %var1%=y goto copies
      goto redo
      :copies

      Color 0A

      xcopy "c:\Program Files\NewLeads\FAILSAFE" %varDesktop%\FAILSAFE /-y /I
      xcopy "c:\Program Files\NewLeads\%varShow%.mdb" %varDesktop%\ /-y
      xcopy "c:\Program Files\NewLeads\%vardate%.log" %varDesktop%\ /-y
      xcopy "c:\Program Files\NewLeads\%varSurvey%" %varDesktop%\ /-y

      ECHO *********************************************************

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Yes/No Command?
      « Reply #10 on: October 21, 2005, 07:50:43 PM »
      An aplogy is in order. I feel truly humble and derilict in my accuracy. Try this:

      Code: [Select]

      :start
      set /p var=This will copy %varFileName% to %varLocation%, if you would like to continue press Y, or press N
      if /i %var%==Y goto LabelA
      if /i %var%==N goto :eof
      goto start

      :LabelA

      do the XCOPY here


      DOS code is very demanding. You might want to consider Windows Scripting.

      8)
      « Last Edit: October 21, 2005, 07:57:33 PM by Sidewinder »
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      PHREKER

      • Guest
      Re: Yes/No Command?
      « Reply #11 on: September 15, 2007, 03:45:42 PM »
      Hi I had the same problem you have just had and thanks to this post i just figured it out the code for the yes/no command on windows XP is



      SET /P CHOICE="WHAT EVER YOU WANT TO SAY? (Y/N)"  (Y/N)

      IF CHOICE=='Y' GOTO ....
      i think you have it from here....

      Dark Blade

      • Forum Gaming Master


      • Adviser

        Thanked: 24
        • Yes
      • Experience: Experienced
      • OS: Windows XP
      Re: Yes/No Command?
      « Reply #12 on: September 15, 2007, 05:02:11 PM »
      Hi I had the same problem you have just had and thanks to this post i just figured it out the code for the yes/no command on windows XP is



      SET /P CHOICE="WHAT EVER YOU WANT TO SAY? (Y/N)"  (Y/N)

      IF CHOICE=='Y' GOTO ....
      i think you have it from here....
      First posted: Posted on: October 19, 2005, 12:51:37 AM

      WHY did you revive this...

      contrex

      • Guest
      Re: Yes/No Command?
      « Reply #13 on: September 15, 2007, 05:34:17 PM »
      Some people never look at the last post's date before diving in...

      patio

      • Moderator


      • Genius
      • Maud' Dib
      • Thanked: 1769
        • Yes
      • Experience: Beginner
      • OS: Windows 7
      Re: Yes/No Command?
      « Reply #14 on: September 15, 2007, 07:00:12 PM »
      Now we can finally hear from the original poster and see if his woes are cured...
      " Anyone who goes to a psychiatrist should have his head examined. "