Computing.Net > Forums > Programming > Bat file to ping

Bat file to ping

Reply to Message Icon

Original Message
Name: sype
Date: July 10, 2007 at 09:49:14 Pacific
Subject: Bat file to ping
OS: mspro sp 2
CPU/Ram: p4, 512
Model/Manufacturer: dell
Comment:

Ok, so i was doing some research, and i came upon a post here along time ago, and i was wondering if you see anything wrong with this. When i run the program, you will see below what errors i get. If any one can help that would be great!


:: multiIP.bat
@echo off > pingLOG.txt
type "C:\Documents and Settings\ssimmons\My Documents\Printer Ping Log and batch"
pause

for /f "tokens=*" %%I in ("C:\Documents and Settings\ssimmons\My Documents\Printer Ping Log and batch") do call :pinger %%I
goto :eof

:pinger

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


This is the outcome....

Access is denied.
Press any key to continue . . .
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.
The process cannot access the file because it is being used by another process.



Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: July 10, 2007 at 11:33:54 Pacific
Reply: (edit)

I suppose "mspro sp 2" means XP.

The reason for this error: "The process cannot access the file because it is being used by another process." is because you're trying to read and write the file at the same time.

well... pretty confusing.

If what you want is to ping a list of IPs and keep a log, try this:

::== ping a list of IPs and log

@echo off > pinglog
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in (IPlist.txt) do (
echo -------------- >> pinglog
echo %date% %time% >> pinglog
ping %%a >> pinglog
)
::== DONE



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Bat file to ping 

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 6 Days.
Discuss in The Lounge