I'm trying to prompt user for input in the batch file with default value (in case user doesn't enter input).
I am trying as given below: default values required: 1 to head.
set rev1=1
set rev2=HEAD
set /p rev1="start rev: default is %rev1% "
set /p rev2="end rev: default is %rev2% "
However prompt shows start rev: default is
instead of start rev: default is 1
.
Please help.
I've tried c&p your code into a bat file and the output is start rev: default is 1
. I guess you've posted just a snippet of your code and the this part is inside an IF or a FOR block. In this case you should add SETLOCAL EnableDelayedExpansion
at the beginning of your script and access rev1 and rev2 with !rev1!
and !rev2!
instead of %rev1%
and %rev2%
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With