Break on
function Ping($Computer,$GetIP,optional $LoopCount,optional $TimeOut)
if $GetIP
dim $ip, $ipfile, $
$ipfile = @scriptdir + '\ip.txt'
shell '%Comspec% /q /e:1024 /c for /F "tokens=2 delims=[]" %%i IN ('+ chr(39)
+ '"ping ' + $Computer1 + ' -n 1 | find "]""' + chr(39) + ') do echo %%i >"' + $ipfile + '"'
$ = open(10,$ipfile,2) $ip = readline(10) $ = close(10) del $ipfile
if $ip
$Ping = $ip
else
$Ping = 'Bad IP address ' + $Computer + '!'
endif
exit 0
else
if $TimeOut
for $c = 0 to $LoopCount
shell '%Comspec% /C ping ' + $Computer + ' -n 1 -w ' + $TimeOut + ' | find /C "TTL=" > nul'
if @error = 0
$Ping = 1
exit 0
endif
next
else
for $c = 0 to $LoopCount
shell '%Comspec% /C ping ' + $Computer + ' | find /C "TTL=" > nul'
if @error = 0
$Ping = 1
exit 0
endif
next
endif
$Ping = 0
endif
endfunction
; Declare variables to prevent scope creep
Dim $InFile, $OutFile ; file names for input and output
Dim $Computer ; computer name, from input file
Dim $Rc ; return-code catcher
Dim $Version ; Version data from Computer
$Rc = SetOption('NoVarsInStings', 'On')
$OutFile = ('c:\test\version.txt')
$InFile = ('c:\test\ie8.txt')
; Open the input file - no strings in quotes!
If Open( 1 , $InFile) <> 0
'Failed to open ' $InFile ' - aborting!' ?
Exit 1
EndIf
; same for the output file
If Open( 2 , $OutFile, 5) <> 0
'Failed to open ' $OutFile ' - aborting!' ?
Exit 1
EndIf
; Read the first line, then loop until EOD (End Of Data) error
$Computer = ReadLine(1)
While Not @ERROR
'Computer: ' $Computer ? ; display the current computer
; Only read the registry if the computer is online
If Ping($Computer)
$Version = Readvalue('\\' + $Computer + '\HKLM\SOFTWARE\Microsoft\Internet Explorer', 'Version')
Else
$Version = 'PC Not Online' ; no ping response
EndIf
; If the registry data is blank, provide appropriate message
$Version = IIf($Version, $Version, 'Invalid data from PC')
'Version: ' $Version ? Display version
$Rc = WriteLine(2, $Version + ',' + $Computer + @CRLF)
$Computer = ReadLine(1)
Loop
$Rc = Close(1)
$Rc = Close(2)