Wow, never thought I would ever write anything in DOS. Now that I do, I know why I never wanted to. The syntax is absurd!
Anyways I need help please.
I would like to prompt the user for input, and if a blank line is received, I would like to use the default value, like this:
set name=abraham.
set /p input=please enter your name, press enter to use %name%:
if not %input%=="" set name=%input%
echo your name is %name%
I get an error says “set was unexpected at this time.”
Can you help please?
Try
Note that in cmd files, if nothing is entered, the var is not changed.
Or, with the if:
Note the quotes around input in the if statement, and notice that I am clearing out input before running (or it will hold the last value if nothing is entered by the user)