tags:

views:

453

answers:

2

How to proceed with an interactive batch file?

Eg.,

DO you want to continue? [y/n]

If 'y' Goto Label1

Else Goto Label2

Thanks

+3  A: 

You can use the SET command. The following is the DOS command equivalent of the pseudo code you have above:

set /p choice=Do you want to continue? [y/n]
if '%choice%'=='Y' goto label1
goto label2
Darksider
if '%choice%' == 'Y' goto label1conditional operator. = dint work for me!
Bharani
my apologies - i'll edit it now
Darksider
You may also consider adding a /i to the if so the comparison is not case-sensitive.
Joey
Rossel, where should I add the /i? Can you gimme the statement?
Bharani
+2  A: 

Using the choice command, you can specify a set of valid characters and a message:

choice /C YN /M "Do you want to continue?"
if errorlevel 2 goto labelno
if errorlevel 1 goto labelyes
Timbo