windows 使用批处理文件超时而不回显命令?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17829884/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 10:44:55  来源:igfitidea点击:

Use batch file timeout without echoing command?

windowsbatch-filecmd

提问by pminogue

I'm fairly new to batch scripting but reasonably competent with programming in general. I'm currently calling a perl script from a batch file and am displaying the result from the perl script in the Windows command window for 10 seconds before exiting the command window.

我对批处理脚本相当陌生,但总体上可以合理地胜任编程。我目前正在从批处理文件调用 perl 脚本,并在退出命令窗口之前在 Windows 命令窗口中显示 perl 脚本的结果 10 秒钟。

I'm using the command

我正在使用命令

timeout /t 10 /nobreak

which is then also printed to the command window after the result of the perl script.

然后在 perl 脚本的结果之后也将其打印到命令窗口。

Is there any way to prevent this so that I just see the result of the perl script and then see the timer counting down?

有什么办法可以防止这种情况发生,以便我只看到 perl 脚本的结果,然后看到计时器倒计时?

I understand I can append '> NUL' to my timeout command to suppress the countdown timer but this isn't what I want to do. I just want to prevent what I see as a line of code printing to the command window. If this can't be done, it's no problem, I'll live with it. But if I can remove it I'd like to.

我知道我可以将 '> NUL' 附加到我的超时命令以抑制倒数计时器,但这不是我想要做的。我只是想阻止我看到的一行代码打印到命令窗口。如果这做不到,也没有问题,我会忍受它。但如果我可以删除它,我想。

Thanks in advance for any help!

在此先感谢您的帮助!

回答by LS_???

If you want to avoid echoing one command, prefix it with @:

如果您想避免回显一个命令,请为其添加前缀@

@timeout /t 10 /nobreak

You can disable echoing at all with command

您可以使用命令完全禁用回显

echo off

Normally, you put

通常,你把

@echo off

at beginning of batch file, so commands are not outputed.

在批处理文件的开头,所以不输出命令。

回答by user6024091

Try doing,

尝试做,

timeout /t 10 nobreak>nul