How can I run cmd from batch file and add text to line without executing?

前端 未结 4 1254
慢半拍i
慢半拍i 2020-12-04 03:46

I want to make file.bat that should run my jar only when user press enter. Bat must run and does\'t execute anything without user press enter. In cmd should be printed:

4条回答
  •  执笔经年
    2020-12-04 04:36

    @echo off
    cls
    echo java -jar crawler-1.0.jar
    echo Press ENTER to continue
    pause > nul
    
    
    1. line = standard start of batch-file
    2. line = clears the screen so that only your wanted text will appear
    3. line = displays the text you wanted
    4. line = tells the user what to do (it will actually activate regardless of key entered; you can't choose that) [optional of course]
    5. line = regular pause command - > nul does only hide the "press a key" in favour of your 4th line custom message, or no message at all
    6. line = enter your desired run code

    I can't comment, so answer to comment question is here:

    @echo off
    :start
    cls
    echo java -jar crawler-1.0.jar
    echo Press ENTER to continue
    pause > nul
    
    goto start
    

提交回复
热议问题