| 1. |
Solve : SET variable not working in an 'if' or 'for' loop of windows batch script? |
|
Answer» Once I get into a 'if' block or 'for' loop in a batch script, it doesn't recognize the SET variable. I found something about CMD /V:ON to enable the delayed execution in a batch script; but then how would you run it in a batch script. When I enabled the CMD /V, the batch script won't run any further beyond that.
This second script will work because delayed expansion is enabled and because !number! and !answer! have exclamation marks INSTEAD of percent signs. Once you are outside the IF block or loop you can use the variables with % signs and they will show up. Quote
|
|