In a windows batch file I want to ask the user for an input, I want to show the user a default value which is the folder where the bat file reside. So when running the batch file the batch check the current folder and set the default variable to it then user can accept the suggested value by clicking on enter or enter a different value. i tried this code but it doesn't work, the UserInputPath is not set.
set default=ABCD
set /p UserInputPath=%default%
echo %UserInputPath%
You asked for user can accept the suggested value by clicking on enter or enter a different value.
Take advantage of the behavior of set /p: if the input is empty (just ENTER), the variable keeps unchanged. So you can simply set a default value:
set "UserInputPath=ABCD"
set /p "UserInputPath=Enter path or just ENTER for default [%UserInputPath%] : "
echo %UserInputPath%
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