简体   繁体   中英

@echo off is not working in batch scripts

I Have several batch scripts on my computer, many of the harmless and annoying. Unfortunately, @echo off just isn't working on my computer.

Here is the script:

@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)

Normally it wouldn't show the cmd. However, I can see the command prompt clear as day.

Seems like you want to hide the output of the comments rather than the prompt and themselves. This can be done by redirecting their STDOUT and STDERR to NUL .

If you start your batch file from cmd, then start it with:

(batch.bat)>NUL 2>&1

and if you start it by double-click, then either create another batch file with content:

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

or in your batch file, start with (not highly recommended):

@echo off
setlocal EnableDelayedExpansion

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

but note that you should access variable with !var! rather than %var% , that's why I don't recommend this way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM