禁用Windows bat脚本中的"暂停"

Dil*_*lon 8 python windows cmd batch-file

在Windows中,我正在运行一个当前以"暂停"结束的蝙蝠脚本,并提示用户"按任意键继续......"

我无法在这种情况下编辑文件,我需要脚本终止而不是挂起等待永远不会来的输入.有没有办法可以运行它来禁用或绕过提示?

我已尝试输入管道,似乎没有帮助.这个脚本是通过subprocess.Popen从python运行的.

Max*_*mus 14

尝试执行 cmd.exe /c YourCmdFile < nul

YourCmdFile - 批处理脚本的完整路径


Bry*_*nta 5

subprocess.call("mybat.bat", stdin=subprocess.DEVNULL)
Run Code Online (Sandbox Code Playgroud)

mybat.batnulWindows 上调用和重定向输入(禁用暂停,如其他答案所示)