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

前端 未结 8 1054
野趣味
野趣味 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:49

    The method below have the inconvenience that the screen must be cleared before the user enter the data, but I am working trying to solve this point:

    EDIT: I fixed the detail of the first version

    @if (@CodeSection == @Batch) @then
    
    @echo off
    rem Enter the prefill value
    CScript //nologo //E:JScript "%~F0" "First Last"
    rem Read the variable
    echo -----------------------------------------------------------
    set /P "Author=Please enter your name: "
    echo Author=%Author%
    goto :EOF
    
    @end
    
    WScript.CreateObject("WScript.Shell").SendKeys(WScript.Arguments(0));
    

    For further details, see this post.

提交回复
热议问题