回声关闭,但显示消息 [英] Echo off but messages are displayed

查看:174
本文介绍了回声关闭,但显示消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我bat文件关闭回声。

I turned off echo in bat file.

@echo off

然后我做这样的事情。

then I do something like this

...
echo %INSTALL_PATH%
if exist %INSTALL_PATH%(
echo 222
...
)

和我得到的:

系统找不到指定的路径。

The system cannot find the path specified.

这两个回波之间的消息。

message between those two echos.

有什么可以此消息的原因,以及为什么消息会忽略掉呼应?

What can be the reason of this message and why message ignores echo off?

推荐答案

Nakis说,回声关闭仅prevents命令,而不是结果的打印。若要隐藏命令的结果添加> NUL 到行的末尾,并隐藏错误添加 2 - ; NUL 。例如:

As Mike Nakis said, echo off only prevents the printing of commands, not results. To hide the result of a command add >nul to the end of the line, and to hide errors add 2>nul. For example:

Del /Q *.tmp >nul 2>nul

克里斯特·安德森说,你会得到一个错误的原因是你的变量是扩大与空间:

Like Krister Andersson said, the reason you get an error is your variable is expanding with spaces:

set INSTALL_PATH=C:\My App\Installer
if exist %INSTALL_PATH% (

变成了:

if exist C:\My App\Installer (

这意味着:

如果C:\\我的存在,运行应用程序\\安装与(作为命令行参数

If "C:\My" exists, run "App\Installer" with "(" as the command line argument.

您看到的错误,因为你没有一个名为应用程序文件夹中。把引号的路径周围prevent这种分裂。

You see the error because you have no folder named "App". Put quotes around the path to prevent this splitting.

这篇关于回声关闭,但显示消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆