need help on batch files

Status
Not open for further replies.

bat2ray

Baseband Member
Messages
29
hi everyone...

need help on this situation.

i have around 100+ pc connecting in a 4different subnet.
sometime some of the pc is currently offline.
i need to have a report in txt file that show me which com is still online.and if can the offline pc also. is there is a way to do that with batch file?
 
I actually found this on the Internet and I modify it so it would work for you.

Create a new folder and call it whatever you want (example batchfolder). In it create a new text file and copy the following below and save it as ScanIP.bat file.

:: ScanIP.bat
@echo off> pingLOG.txt

for /f "tokens=*" %%I in (IPlist.txt) do call :pinger %%I
goto :eof

:pinger

echo %TIME% >> pingLOG.txt
ping -n 1 %1 >> pingLOG.txt
:: DONE




Now you will have to create another text file call IPlist.txt and put in every IP address of the computer you want to ping in it. This file will be the input. Make sure itÂ’s in the same folder as ScanIP.bat.
Example: A list of IP in vertical order
192.168.1.1
192.168.1.2
and so on

To use it open up command prompt, navigate to the folder where you created ScanIP.bat and IPlist.txt. Execute the program by typing scanip.bat, depending on the amount of your computer in the list it will take awhile. It will create an output file call pingLOG.txt in the same directory. You can click on it while itÂ’s running to check the conditions. Close it and open it up to update it while itÂ’s running.

Something you should know:
The line @echo off> pingLOG.txt tells the batch file to clear the old log and write over it. Meaning you get a fresh file every time you run the batch.

You can add more options to the ping command at the line ping -n 1 %1 >> pingLOG.txt
Notice the –n 1 that means to send 1 echo request, you can change the number higher but 1 will be faster.
 
Status
Not open for further replies.
Back
Top Bottom