In question 22970139 an expert helped me develop the simple vbscript shown below that basically pings each server listed in an external text file, then returns a result for each server, formats all the results into a single string and then passes the string as the subject of a command line emailer (BMail). The script works a treat, but it was mentioned that I could also build in a FileSystem check to check the availability of the C$ share on each server being tested, as extra proof the server is alive.
So how in VBScript would I go about checking whether the C share on a remote server is 'accessible'?
SET objFSO = CreateObject("Scripting.FileSystemObject")
SET objInputfile = objFSO.OpenTextFile("serverhealthcheckserverlist.txt")
Set objShell = WScript.CreateObject( "WScript.Shell" )
resultsStr = ""
DO WHILE NOT objInputfile.AtEndOfStream
strComputer = objInputfile.readline
SET objExec = objShell.Exec("ping -n 2 -w 1000 " & strComputer)
strPingResults = LCase(objExec.StdOut.ReadAll)
IF InStr(strPingResults, "ttl") THEN
resultsStr = resultsStr & strComputer & "_OK__"
resultsStr = resultsStr & strComputer & "_FAIL__"
objShell.Run("bmail -s grj-exch01 -t ITalert@greatrail.com -f email@example.com -h -a ServerHealth -b " & resultsStr)
Set objShell = Nothing
Set resultsStr = Nothing