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

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.

Bat file to ping

Reply to Message Icon

Name: sype
Date: July 10, 2007 at 09:49:14 Pacific
OS: mspro sp 2
CPU/Ram: p4, 512
Product: 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.




Sponsored Link
Ads by Google

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

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



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 Programming Forum Home


Sponsored links

Ads by Google


Results for: Bat file to ping

ping bat file www.computing.net/answers/programming/ping-bat-file/16605.html

.bat file to open multiple programs www.computing.net/answers/programming/bat-file-to-open-multiple-programs/7546.html

BAT file to open multiple windows www.computing.net/answers/programming/bat-file-to-open-multiple-windows/7513.html