Ping results "echo'd" out to a text file on Windows XP machine has unusual character rather than the outcome

Posted by Richard Rice on Super User See other posts from Super User or by Richard Rice
Published on 2014-06-04T14:34:16Z Indexed on 2014/06/04 15:30 UTC
Read the original article Hit count: 166

Filed under:
|
|
|

Here is the situation.

I have a Windows XP machine that I would like to ping another machine and send the output to a text file for review at a later date. This is quite a standard question with several answers on this website and others.

The issue I have is that when reviewing the txt file afterwards, the outcome of the ping appears as a strange character. A screenshot of the text file output can be found at the following link. Please note its the first 8 ping outputs that have a strange character. The %%B was me hoping that would output what I wanted! (Cannot upload image to any hosting websites because the company I work for seems to be afraid of them ....)

enter image description here

Here is the code I'm using:

@echo off
For /f "tokens=1-2 delims=/:" %%b in ("%TIME%") do (set mytime=%%a%%b)
PING 1.1.1.1 -n 1 -w 1000 >NUL
for /f "tokens=*" %%A in ('ping 192.168.5.2 -w 10 -n 1') do (echo %date% %time% %%A >> C:\Temp\Ping_Checks\GarrickSide.txt && GOTO Ping )
:Ping
PING 1.1.1.1 -n 1 -w 1000 >NUL
for /f "tokens=* skip=2" %%A in ('ping 192.168.5.2 -w 10 -n 1') do (echo %date% %time% %%A >> C:\Temp\Ping_Checks\GarrickSide.txt && GOTO Ping )

This code works fine on a Windows 7 machine, but not on a Windows XP machine. It appears that the echo command isn't outputting the right data, but I don't understand this enough to correct it.

Can anyone spot where I'm going wrong?

© Super User or respective owner

Related posts about windows-7

Related posts about windows-xp