执行START命令时,阻止批处理文件显示错误消息

时间:2017-08-06 18:03:34

标签: batch-file

我有一个简单的代码来运行程序,见下文:

@echo off
START Apps\Test.exe
Exit

我希望在所需文件不存在时隐藏错误消息:

Windows cannot find 'Apps\Test.exe'. Make sure you typed the name correctly, and then try again.

START Apps\Test.exe >nul 2>nul无效。

此外,我不想删除START命令,如下所示:Apps\Test.exe因为它会导致批处理文件在Test.exe关闭之前保持打开状态。

有什么办法吗?

1 个答案:

答案 0 :(得分:0)

if exist "Apps\Test.exe" START Apps\Test.exe

应该可以防止您的错误消息出现