Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
1  
And, in most cases, just to be sure, stick a 2>&1 at the end as well. Many programs (ping and find apparently not) emit error messages to stderr. –  Јοеу Oct 21 '09 at 6:26
1  
@Johannes Rössel: No. This is DOS, not Unix. –  Teddy Oct 21 '09 at 9:11
    
Surely it's "nul:", not "nul"? –  Teddy Oct 21 '09 at 9:12
    
I think people use nul: because files cannot be created with a colon in their name on Windows, so it will revert to nul by itself. Even an example from Microsoft on how to invoke DOS commands uses nul by itself: support.microsoft.com/kb/40592 –  John T Oct 21 '09 at 11:48
    
Thank You sir! Great Success (*With borat accent) –  thegreyspot Oct 22 '09 at 2:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.