Is there a way to present a default value in a set /p
statement in a Windows batch script?
For example, something like this:
set /p MyVar=My Default Value
echo $MyVar$
If the user presses Enter without typing anything else, then `MyVar gets that default value.
Thanks.
The solutions proposed above did not work for me or they worked in a very clunky way.
This is (an obvious) simple solution to the problem I applied:
SET Docdir=D:\Documents\
SET /p Docdir="Target directory (Press Enter to keep <%Docdir%>): "
It results in the following prompt:
Target directory (Press Enter to use <D:\Documents\>):
User then see what's the default value and can accept it with Enter
key
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With