如何从批处理文件运行cmd并将文本添加到行而不执行?

Ole*_*nko 1 command-line cmd batch-file

我想制作仅当用户按Enter键时才运行jar的file.bat。未经用户按Enter键,Bat必须运行并且不执行任何操作。在cmd中应打印:

java -jar crawler-1.0.jar
Run Code Online (Sandbox Code Playgroud)

该用户的一部分可以更改this.text

我怎样才能做到这一点?

Aac*_*ini 6

劳驾。我认为这个问题的真正目标是:“如何使用可编辑的字符串预填充cmd.exe命令行输入”,因此用户可以按Enter键执行预填充的输入,或以任何所需的方式对其进行编辑。我从这篇文章中复制了以下方法:

@if (@CodeSection == @Batch) @then

@echo off
rem Enter the prefill value in the keyboard buffer
CScript //nologo //E:JScript "%~F0" "java -jar crawler-1.0.jar"
goto :EOF

@end

WScript.CreateObject("WScript.Shell").SendKeys(WScript.Arguments(0));
Run Code Online (Sandbox Code Playgroud)