我可以在不换行的情况下运行 CMD 命令吗?

dit*_*ncy 1 windows batch-file

我正在尝试运行暂停命令而不显示它Press any key to continue . . .并且不创建新行?我尝试了有人建议的在不换行的情况下回显文本的方法,但这对我不起作用。

pause>nul据我所知,但这创建了一条新线。

这是一个例子:

This is some sample text.
Run Code Online (Sandbox Code Playgroud)

脚本会暂停,直到按下某个键。

然后它处理剩下的部分:

This is some sample text.Here is the rest.
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏。

Som*_*ark 5

不可以,命令内置于 cmd 可执行文件中,并且它们的行为无法更改。但是,您可以使用 echo(或<nul set /p =在您的情况下为 a)模拟命令输出。

@echo off

REM Write the same message that pause prints, but do not include a newline
set /p "=Press any key to continue..." <nul

REM Pause without output
pause >nul

REM Prove that we're still on the same line
echo This is on the same line
Run Code Online (Sandbox Code Playgroud)