Computing.Net > Forums > Windows 2000 > Trying to make batch / cmd file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Trying to make batch / cmd file

Reply to Message Icon

Name: Mark
Date: April 7, 2003 at 12:58:40 Pacific
OS: WinNT
CPU/Ram: 400MHz and 64MB
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Lucid
Date: April 8, 2003 at 11:11:44 Pacific
Reply:

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


0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Windows 2000 Forum Home


Sponsored links

Ads by Google


Results for: Trying to make batch / cmd file

How do I make a .bat file to shutdown co www.computing.net/answers/windows-2000/how-do-i-make-a-bat-file-to-shutdown-co/17617.html

explorer error when trying to find files www.computing.net/answers/windows-2000/explorer-error-when-trying-to-find-files/18866.html

Apps. trying to connect to... www.computing.net/answers/windows-2000/apps-trying-to-connect-to/55041.html