bluegaptek

Ping request timed out script

9 posts in this topic

Hi, I'm noobs to autoit.

Need simple script for ping loop, and if "request timed out" run specific application. 

Share this post


Link to post
Share on other sites



Buy one (but not here) or try to write your own. But note: not every webserver answers on a ping.
For starting have a look in helpfile about:

Quote

Ping

Pings a host and returns the roundtrip-time.

 

Share this post


Link to post
Share on other sites
11 hours ago, AutoBert said:

Buy one (but not here) or try to write your own. But note: not every webserver answers on a ping.
For starting have a look in helpfile about:

 

I started with example script but can only get return value of 0 = failure.

How to return value @error (e.g Host is offline)

Share this post


Link to post
Share on other sites

What have you tried? Post your script.

Share this post


Link to post
Share on other sites
6 hours ago, InunoTaishou said:

What have you tried? Post your script.

Local $iPing = Ping("192.168.22.1", "250")
MsgBox($MB_SYSTEMMODAL, "", "The roundtrip-time took: " & $iPing & "ms.")

How to get specific value of error ?

Share this post


Link to post
Share on other sites
Quote

Return Value

Success: the roundtrip-time in milliseconds ( greater than 0 ).
Failure: 0 if host is not pingable or other network errors occurred and sets the @error flag to non-zero.
@error: 1 = Host is offline
2 = Host is unreachable
3 = Bad destination
4 = Other errors
Local $iPing = Ping("192.168.22.1", "250")

Switch (@Error)
    Case 1
        MsgBox("", "", "Host is offline.")  ; I hope it's not, then you have no internet!
    Case 2
        MsgBox("", "", "Host is unreacable.")
    Case 3
        MsgBox("", "", "Bad destination.")
    Case 4
        MsgBox("", "", "Other errors.")
    Case Else
        MsgBox($MB_SYSTEMMODAL, "", "The roundtrip-time took: " & $iPing & "ms.")
EndSwitch

 

1 person likes this

Share this post


Link to post
Share on other sites
1 hour ago, InunoTaishou said:
Local $iPing = Ping("192.168.22.1", "250")

Switch (@Error)
    Case 1
        MsgBox("", "", "Host is offline.")  ; I hope it's not, then you have no internet!
    Case 2
        MsgBox("", "", "Host is unreacable.")
    Case 3
        MsgBox("", "", "Bad destination.")
    Case 4
        MsgBox("", "", "Other errors.")
    Case Else
        MsgBox($MB_SYSTEMMODAL, "", "The roundtrip-time took: " & $iPing & "ms.")
EndSwitch

 

Hey thanks, this is what I need.

But autoit ping return "Host is unreachable" while I don't have internet connection and windows ping show "request timed out" :(

Since I need this to reconnect wifi (fyi: sometimes my wifi status connected but can't reach internet, but by reconnecting I'm able to reach internet again)

Is there anyway around to accomplish this ?screenshot_00036.thumb.png.fd7a4576f5976

 

Share this post


Link to post
Share on other sites

You're pinging your router and getting host unreachable (same thing as timed out, means windows tried to send data to the ip but didn't get a reply within the time limit). Sounds like you need to disconnect then reconnect. I usually disable my adapter then re-enable it. I'm sure there's a UDF floating around on the forum somewhere for reconnecting to wifi or disable/enable your network adapter.

Share this post


Link to post
Share on other sites
24 minutes ago, InunoTaishou said:
24 minutes ago, InunoTaishou said:

You're pinging your router and getting host unreachable (same thing as timed out, means windows tried to send data to the ip but didn't get a reply within the time limit). Sounds like you need to disconnect then reconnect. I usually disable my adapter then re-enable it. I'm sure there's a UDF floating around on the forum somewhere for reconnecting to wifi or disable/enable your network adapter.

You're pinging your router and getting host unreachable (same thing as timed out, means windows tried to send data to the ip but didn't get a reply within the time limit). Sounds like you need to disconnect then reconnect. I usually disable my adapter then re-enable it. I'm sure there's a UDF floating around on the forum somewhere for reconnecting to wifi or disable/enable your network adapter.

Ok, now I get it, I use windows cmd or batch to reconnect the network adapter.

Thank you for the code, really appreciate that.

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