Hi,
I am a desktop support and one of my daily duties it to check if printers are alive. I have a batch file to do that but sometimes first ping fails so i only want to record an outcome of the senond one. Could you please help me change my batch file to address this?
Thanks guys this will save me a lot of effort
echo off
if exist c:\printersUnit3.txt goto Label1
echo.
echo Cannot find c:\printersUnit3.txt
echo.
Pause
goto :eof
:Label1
(Set OutputFile=c:\resultUnit3.txt)
If Exist "%OutputFile%" Del "%OutputFile%"
echo PingTest for printers at Unit 5 executed on %date% at %time% > "%OutputFile%"
echo ================================================= >>"%OutputFile%"
for /f %%i in (c:\printersUnit3.txt) do call :Sub %%i
notepad "%OutputFile%"
goto :eof
:Sub
echo Testing %1
set state=alive
ping -n 1 %1 | find /i "bytes=" || set state=dead
echo %1 is %state% >> "%OutputFile%"
pinging batch
Started by timmy3, Jun 18 2010 07:56 AM
1 reply to this topic
#1
Posted 18 June 2010 - 07:56 AM
|
|
|
#2
Posted 30 June 2010 - 08:00 PM
I have had the same problems with batch. My first language I learn't, and the print syntax is a pain in the neck. Also, you should use code tags when posting code on the forum, it makes things alot neater.
Whats in C:\printersUnit3.txt? Just out of curiosity. If the printers are on the same LAN, maybe you ought to do this:
This will loop the pings, yet it won't crash it because you can set the number of bytes lower...Just a thought.
Or, to record it:
That should record the output to a textfile of you choice.
Whats in C:\printersUnit3.txt? Just out of curiosity. If the printers are on the same LAN, maybe you ought to do this:
ping xxx.xxx.xxx.xxx -l numberofbytestosend
This will loop the pings, yet it won't crash it because you can set the number of bytes lower...Just a thought.
Or, to record it:
ping xxx.xxx.xxx.xxx >> anytextfile.txt
That should record the output to a textfile of you choice.


Sign In
Create Account

Back to top









