Sign in to follow this  
Followers 0
Andre

Ping Test

1 post in this topic

Hi,

Some code to "ping" various hosts to see if they are alive.

Create an pingtesthosts.txt in the same directory where the script is running.

Should contain the hostnames (ip's)

----------------------------------------------------------------------------
;
; AutoIt Version: 3.0
; Language:       English
; Platform:       Win9x / NT
; Author:         Andre Jeanmaire (andre.jeanmaire@mm-karton.com)
;
; Script Function:
;   Ping various hosts to see if they exist.
; Read them from PingTestHosts.txt
; ----------------------------------------------------------------------------

HotKeySet("^+~","Exitfunc")


$HostFile = "PingTestHosts.txt"

$sCmd = "ping.exe"
$SOption  = "-w 50"


While 1
$file = FileOpen($HostFile, 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(16,"Error","Sorry can't proceed." & @CRLF & "The File : 'PingTestHosts.txt' is missing in application directory")
    Exit
EndIf


    
; Read in lines of text until the EOF is reached

    While 1
    $Host = FileReadLine($file)
    If @error = -1 Then ExitLoop
    $SCmdParm = $Host   
  $iRetCode = RunWait( $sCmd & " " & $sCmdParm & " " & $SOption,"",@SW_hide)
  If $IRetCode = 1 Then
     TrayTip("Ping ?","No answer from " & $Host & " at : " & @HOUR & ":" & @MIN & ":" & @SEC ,25, 3)
  EndIF
    WEND
  FileClose($File)
    Sleep(60000); Every minute
Wend

Func ExitFunc()
    $Answer = MsgBox(4,"PingTest", "End Program ? ")
    If $Answer <> 7 Then Exit

EndFunc

What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0