Here is one method.
It will set %1
as myvar
if defined, then skip the prompt and echo myvar
else it will store Default Value
as the default, but if someone types in another value, it will overwrite the default. Not you can also use %2
%3
etc.
@echo off
set "myvar=%1"
if "%myvar%"=="" set /p "myvar=Enter Value: " || set "myvar=Default Value"
echo %myvar%
to see results, save the batch and run the following from cmdline
:
batchfile.cmd Default
Which will skip prompt and just echo:
Default
batchfile.cmd
Which will prompt Enter Value:
just hit enter, which will then echo:
Default Value
Lastly
batchfile.cmd
and enter a value, which wil lecho the entered value.