Batch File: Hide Ping test results
26,710
redirect the output to nul
:
ping -n 1 %computer_name% | find "Reply" > nul
this will still correctly set the %errorlevel%
if the string was or was not found, but also hide the output.
Related videos on Youtube
Author by
thegreyspot
Updated on September 17, 2022Comments
-
thegreyspot over 1 year
I'm making a batch file that tests a Computer name and sees if it responds.
However when I run it, even with the "@echo off", I still see the reply being sent and so on. How can I hide that?
-
Joey over 14 yearsAnd, in most cases, just to be sure, stick a
2>&1
at the end as well. Many programs (ping
andfind
apparently not) emit error messages to stderr. -
Teddy over 14 years@Johannes Rössel: No. This is DOS, not Unix.
-
Teddy over 14 yearsSurely it's "
nul:
", not "nul
"? -
John T over 14 yearsI think people use
nul:
because files cannot be created with a colon in their name on Windows, so it will revert tonul
by itself. Even an example from Microsoft on how to invoke DOS commands usesnul
by itself: support.microsoft.com/kb/40592