problem in batch script read user input

Posted by JCH on Stack Overflow See other posts from Stack Overflow or by JCH
Published on 2010-06-11T18:10:07Z Indexed on 2010/06/11 18:12 UTC
Read the original article Hit count: 276

Filed under:
|
|
|

hi,

i use set /p below to read user input it seems to work outside the if block but the one inside if block doesn't work. When i run the script second time the user input in the if block prints the previous user input.

test script:

@echo off
set cond=true
echo %cond%
if %cond%==true (
echo "cond is true"
REM the below input doesn't work
set /p name1="enter your name"
echo name is: %name1%
)

REM it works here
set /p name2="enter your name"
echo name is: %name2%

thank you

© Stack Overflow or respective owner

Related posts about Windows

Related posts about batch