0

I working on small program to update the configuration of small program, I'm new to batch script,
user need to enter desired input to go to desired program and I have 5 set of programs with in the batch file and I don't know how to set a program if user not entered any number and pressed enter in that case I need to go to begin

:begin
SET /P runscript="Press The Desired Key and Press Enter ="
if %runscript%==1 goto setup
if %runscript%==2 goto start
if %runscript%==3 goto show
if %runscript%==4 goto stop
if %runscript%==5 goto end

How can I do that?

1 Answer 1

2

Solution

First you should make sure the runscript variable is empty, and then you check whether it's actually defined:

:begin
set runscript=
set /p runscript="Press The Desired Key and Press Enter ="
if not defined runscript goto :begin

if %runscript% == 1 goto :setup
if %runscript% == 2 goto :start
if %runscript% == 3 goto :show
if %runscript% == 4 goto :stop
if %runscript% == 5 goto :end

Further reading

You must log in to answer this question.