Saturday, February 2, 2008

Ping and check for success in VBScript

Here is a quick piece of VBScript code that does a ping via the shell object. Then parses the results that were dumped into a text file to check for success. It pings PCs that are in the C:\Computers.txt file. One PC name per line. In the strSuccess=No part you would place the activities for a failed ping which will likely be nothing or possibly writing to a log. In the strSuccess=Yes you would place whatever code needs to be done on the PC name...in my case it is usually some kind of wmi or registry edit. There are other ways to do this such as the WMI class Win32_PingStatus(Only works on XP or later).

No comments: