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

Author Topic: Varification Test  (Read 2483 times)

0 Members and 1 Guest are viewing this topic.

MIKEY9821

    Topic Starter


    Newbie

    Varification Test
    « on: July 28, 2009, 02:08:22 PM »
    I would like to have my batch file ask if I am sure I want to continue before it runs. I very new to batch files but so fare have be able to create one to perform a tedious task.

    IF NOT EXIST O:\ARCHIVE\%1\NUL MD O:\ARCHIVE\%1
    XCOPY /E F:\ACAD\%1\*.* O:\ARCHIVE\%1
    XCOPY /E F:\ADMIN\%1\*.* O:\ARCHIVE\%1
    rmdir F:\ACAD\%1 /s
    rmdir F:\ADMIN\%1 /s

    I want to have the batch ask "Are you sure you want to Archive job %1?"

    then I can enter "Y" or "N".

    Can any one help me do this or point me to an example I can use?

    BatchFileBasics



      Hopeful

      Thanked: 18
      Re: Varification Test
      « Reply #1 on: July 28, 2009, 11:17:08 AM »
      very simple, using set /p to capture user input:

      Code: [Select]
      :start
      set input=
      set /p input=Are you sure you want to Archive job %1?
      if /i %input% equ y goto yes
      if /i %input% equ n goto no
      goto start

      :yes
      rem code here
      exit

      :no
      exit

      i haven't tested this code, but under yes. you will put your code if they want to, and no... you get the idea
      When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.

      Salmon Trout

      • Guest
      Re: Varification Test
      « Reply #2 on: July 28, 2009, 07:31:40 PM »
      very simple, using set /p to capture user input:

      i haven't tested this code, but under yes. you will put your code if they want to, and no... you get the idea

      If you use EQU and no quotes, what happens when the user just presses ENTER? To avoid a crash I suggest this change:

      Code: [Select]
      if /i "%input%"=="y" goto yes
      if /i "%input%"=="n" goto no