Home > OS >  The bat script variable Settings seem to encounter a BUG
The bat script variable Settings seem to encounter a BUG

Time:10-31

Here's my bat script code:
 
@ echo off
The set var1=
The set var2=

: aa
If "% % var1"=="" goto bb
Set/p var2=please enter the number 2:

If % % var2==2 (
: bb
Echo input var1 before: % var1 %
Set/p var1=please input the value of var1:
Echo input set after check the value of the
The set var1
Echo after input var1 % %
Echo "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -"
Goto aa
)


After the second set the value of var1, echo output is still the old value, but set var1 can display real-time values here

CodePudding user response:

Try this

@ echo off

Echo input var1 before: % var1 %
Set/p var1=please input the value of var1:
The set var1
Echo after input var1 % %
Echo "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -"
Echo input var1 before: % var1 %
Set/p var1=please input the value of var1:
The set var1
Echo after input var1 % %
pause
  • Related