suthers Posted July 21, 2014 Share Posted July 21, 2014 Hi All, My question relates to the behavior of the Ping function under certain conditions. The code for testing this is: $PingResult = Ping("192.168.1.2") MsgBox (0,"Ping Test", "Ping Return Value = " & $PingResult & @CRLF & "@Error Value = " & @error) The IP address above is our local Exchange server. If all is good, it outputs return value of 1 (ms) and @Error of 0 (no error) If I unplug the network cable, it outputs return value of 0 (ms) and @Error of 2 (Host Unreachable) All OK so far! However, if I clean reboot the machine with the network cable disconnected, it gives a return value of 1 (ms) and @Error value of 0 It's driving me batty, as there is no way to distinguish this result from the result returned when all is well and the server response time is 1ms. According the help file on the Ping command I should be testing the return value, and if it is > 0 a successful Ping was obtained - but in the clean reboot situation it is returning a value of 1 when the computer does not even have a valid network connection! If I use the good-old Windows Ping command after the clean reboot, it correctly reports that it cannot send the ping request. Is this a bug in the ping command? Info for replicating the situation: You must use a local IP address, not something requiring DNS resolution like myserver.local. Machine: Windows 7 Pro SP1 32 bit fully patched AutoIT: V3.3.8.1 Thanks very much :-) Bill Link to comment Share on other sites More sharing options...
wisem2540 Posted July 21, 2014 Share Posted July 21, 2014 Personally, I would use Run(Ping) to call the windows one. That is how I have always done it. Link to comment Share on other sites More sharing options...
wisem2540 Posted July 21, 2014 Share Posted July 21, 2014 I actually just had to use this again... Here you go If RunWait("ping.exe -n 1 " & 127.0.0.1, "", @SW_HIDE) == 0 Then; success ;Do successful else ;not successful endif Link to comment Share on other sites More sharing options...
suthers Posted July 27, 2014 Author Share Posted July 27, 2014 Thanks very much for that suggestion for a work-around. Will try that today. I was hoping we could get the native AutoIT function fixed, but no-one seems to be posting in that regard. Link to comment Share on other sites More sharing options...
computergroove Posted July 28, 2014 Share Posted July 28, 2014 Perhaps the network card drivers need time to initialize when windows starts. Try waiting for a minute after the icons appear on the desktop and report back on the results. I run into this kind of thing all the time. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
suthers Posted July 28, 2014 Author Share Posted July 28, 2014 OK - will do. I can't reboot my machine at present as it's running a long connectivity monitoring task for me, but will post back when I do. I'm pretty sure I have already left it quite long (>10 minutes) times and it's still doing it, but will confirm definitely with a specific test. Link to comment Share on other sites More sharing options...
computergroove Posted July 29, 2014 Share Posted July 29, 2014 You say the program works when you run it but fails to work correctly after a reboot. What do you do to get it to work again after a reboot? Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
suthers Posted August 4, 2014 Author Share Posted August 4, 2014 No, sorry, some misunderstanding there. The only condition under which it fails is if the computer is rebooted with the network cable unplugged. The issue is fixed as soon as a valid network is connected, or if the computer is rebooted with the cable in place. Link to comment Share on other sites More sharing options...
computergroove Posted August 4, 2014 Share Posted August 4, 2014 Try pinging google While 1 $var = Ping("www.google.com") If not @error Then ;Your Script Here Else Sleep(1000) EndIf WEnd Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
suthers Posted August 5, 2014 Author Share Posted August 5, 2014 Nice try, but no luck. The script is testing mostly internal addresses, and often (due to our internet arrangements) the internet is inaccessible but the internal addresses are. To kill the script based on loss of Google or DNS isn't an option. Link to comment Share on other sites More sharing options...
computergroove Posted August 5, 2014 Share Posted August 5, 2014 Do you get a reply if the cable is unplugged and you ping 127.0.0.1? If not then replace google with 127.0.0.1. I understand that there seems to be a bug in the internal Ping function within Autoit. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
suthers Posted August 8, 2014 Author Share Posted August 8, 2014 (edited) Thanks so much for all your help on this computergroove. Yes, I do get a reply from 127.0.0.1 when no network is available - identical to the response from other internal network addresses. Drat. That was a good idea :-) I also tested the 'wait for everything to initialize' idea - no luck there either. No matter how long you wait the situation does not change. Looks like the only option at present is to use the Windows ping fuction via RunWait() as you suggested. Is there a way to track whether the developers intend and/or have completed fixing AutoIT's own ping function? Edited August 8, 2014 by suthers Link to comment Share on other sites More sharing options...
computergroove Posted August 8, 2014 Share Posted August 8, 2014 You can submit a bug report. Read the active tickets before you submit anything - http://www.autoitscript.com/trac/autoit/report Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now