Check If A Computer Is Online

08/14/2013 02:20 Liented#1
a copy of my famous (uh? Where?) script to check if a computer is online or not.
Remade in the Au3 sintax!!

Just, as every function, copy in the botton of your script and call it with
_IsTheComputerOn("computername")
Code:
Func _IsTheComputerOn ($computername)

; A function to know if a remote computer is on or not.
; Returns
; 0 if the computer is OFF
; 1 if the computer is ON
; 5 if the computer is the one where the script is executed, so it is of course on...;)

 Local $ping
 Local $computername

 If @computername = $computername Then
    Return 5
 EndIf

 RunWait(@comspec & " /c ping "& $computername &" -n 1 -w 50>"& @tempdir &"\ping.tmp","",@sw_hide)
 $ping = FileReadLine(@tempdir &"\ping.tmp",13)
 FileDelete(@tempdir &"\ping.tmp")
 If StringInStr($ping,"(0%") Then
    Return 1
 Else
    Return 0
 EndIf
EndFunc