A batch file ping looped, with added trace file.
An analyser kept loosing its connectivity to a server and it was not known why. One theory was the analyser (a Windows 10 device, heavily locked down to the point we couldn’t access the desktop) was performing some sort of power saving on the NIC after a period of inactivity.
Background: Once the analyser established a TCP/IP connection with the server, it kept the connection open, rather than an open->communicate->close process. This is seemingly a fairly fragile way to maintain communications especially when there are periods of non-communication (sometimes hours overnight) and the system didn’t perform any validation of an open connection before trying to send anything, which resulted in lots of error messages.
In order to rule out the power saving NIC issue I created a simple batch file script that pinged the analysers NIC every 60 seconds. This is a somewhat crude, yet simple way to keep the NIC from turning off as it shouldn’t have periods of idleness longer than 60 seconds.
@ECHO OFF
set IPADDRESS=[IP Address]
set INTERVAL=60
:PINGINTERVAL
CLS
ECHO Pinging %IPADDRESS%
echo %date% %time% >> trace.txt
ping %IPADDRESS% -n 3 >> trace.txt
timeout %INTERVAL%
GOTO PINGINTERVALAs the script was going to be left running overnight, it was important to be able to monitor its progress, so additional lines were added to output the ping response to a text file that could be reviewed in the morning.
In the end, the issue was a firewall issue, but the script did help to rule out the analyser as the part of the equasion that was causing the problem.
