Is there anyway to have preset data for user input in a batch file?

前端 未结 8 1053
野趣味
野趣味 2020-12-06 19:52

So basically I have a batch file that requires alot of user input. I was wondering if it was possible to have any filler data already present when the question is asked, and

8条回答
  •  时光取名叫无心
    2020-12-06 20:42

    You can set the var first and then prompt the user only if it's not defined like so:

    set Author=First Last
    if not defined Author set /p "Author=Please enter your name: "
    

    You can also do this backwards where you can define a value if the user didn't define it, like so:

    set /p "Author=Please enter your name: "
    if not defined Author set Author=First Last
    

提交回复
热议问题