I have a batch script that has certain variables used as parameters. I predefine the variables at batch file startup and then ask the user whether he would like to change the variables (default / user settings). If the values are to be left to default, the user is supposed to just press ENTER.
I check this via the command
Code: Select all
set /p name_of_variable =
There is one issue I do not quite understand. Running the batch script with default settings right after starting the command window (which means pressing the ENTER key like 5 times in a row) works fine. However if I run the script once, then set some of these variables to say random strings like 'asddaad', after which I launch the batch file again and THEN press ENTER (so to use defaults this time) the output values are still set to the ones from the first launch of the bat file - as in somehow the SET command ignores pressing ENTER and values assigned in this case are somehow taken from some input buffer of the command window (just my hunch, but it seems to work).
Could anybody explain how does that actually work and how to either add something to make my batch file work properly or change the batch file structure so to still have the logic preserved (namely to first set some variables to certain default values and then somehow allow the user to overwrite the ones he wants to).
I'm more or less a beginner to dos batch scripting, so please no complicated replies