Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi. I'm trying to make a batch file that goes through a text file that has a list of computernames, and basically tell me if they are responding or not. It then sends the output to a log file. The problem is that I need to check if it exists first - if it exists, then do a ping, and say that it is responding. If it doesn't exist, say that it is not responding.
To check if the computer exists, I use the IF EXIST command for any file on the C$ share, THEN do something based on the condition.
This does what I want it to do, however it is very time consuming, and inefficient. There has to be a better way.
The computers can be win95, 98, NT, or 2000.
Any ideas anyone?
FOR /f %%i in (C:\pingem\Computers.txt) do (
ECHO trying %%i . . .
(IF EXIST \\%%i\C$\*.* (
ping %%i -n 1 >>C:\pingem\Logfile.log
ECHO %%i is responding.
ECHO %%i is responding. >>C:\pingem\Logfile.log
) ELSE (
ECHO %%i is not responding. >>C:\pingem\Logfile.log
)))

First question...
If you connect to that machine and have it look for a file in C$ drive (your IF EXIST statement), then that means the machine is repsonding (at least that much). So why bother to Ping it at all? You'll get the same result, so drop the Ping stuff and base it on a file in the system (or the other way around).....

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |