_Chris_ Posted September 13, 2006 Share Posted September 13, 2006 i am using the ping command which should ping until it gets a responce, if it does then it moves on the next bit, if it hasent got a reply after 20 seconds it should show the message box. It just comes up streight away! HELP! Func Test() $pres= ping("192.168.1.1",20000) Select Case $pres= "0" MsgBox(0x40, "Conection Failed", "Your network Connection has failed, The program will now exit") EndSelect EndFunc Link to comment Share on other sites More sharing options...
Bert Posted September 13, 2006 Share Posted September 13, 2006 From the helpfile: Failure: Returns 0 if host is not pingable or other network errors occurred and sets @error. (See Remarks) Did you first check to see if the IP was good to test your script? You also may want to set a error statement. Something like this: Func Test() $pres= ping("192.168.1.1",20000) Select Case $pres= "0" MsgBox(0x40, "Conection Failed", "Your network Connection has failed, The error code is" & @error) EndSelect EndFunc The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
_Chris_ Posted September 13, 2006 Author Share Posted September 13, 2006 Thanks for your help! The ip is the router ip so its good! i can ping it from cmd prompt I have the coding i need. That was just a sample. The problem i am having is that it dosent wait 20 seconds before it times out! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 13, 2006 Moderators Share Posted September 13, 2006 Thanks for your help!The ip is the router ip so its good! i can ping it from cmd promptI have the coding i need. That was just a sample. The problem i am having is that it dosent wait 20 seconds before it times out!The timeout portion only happens if it's not returning a ping... if it's returning one, it's not going to wait for 20 seconds. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
_Chris_ Posted September 13, 2006 Author Share Posted September 13, 2006 yes i know thats the point! When my network conection is disconected (e.g. as part of the program i change ip address) during that time it should not be able to ping the address but should wait 20 seconds to give the program chance to renew the ip Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 13, 2006 Moderators Share Posted September 13, 2006 yes i know thats the point! When my network conection is disconected (e.g. as part of the program i change ip address) during that time it should not be able to ping the address but should wait 20 seconds to give the program chance to renew the ipNope, still not getting you... hold on <sips coffee> <hates coffee> So your saying the address no longer exists... but ping is returning saying it does? If the above is true, then how are you changing the address, and how are you confirming other than autoit (manually) that it doesn't exist while your doing whatever you doing? If you need a specific timeout function for something other than what I'm not understanding... you may look at something like: $iTimer = TimerInit() While (Ping("192.168.1.1") Or (TimerDiff($iTimer) / 1000 <= 20)) Sleep(10) WEnd Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
AzKay Posted September 13, 2006 Share Posted September 13, 2006 Hes prolly disconnecting the internet connection, then reenableing it. Thus, renewing the ip. # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
_Chris_ Posted September 13, 2006 Author Share Posted September 13, 2006 _RunDos('netsh interface ip set address name="Wireless Network Connection" source=static addr=192.168.1.10 mask=255.255.255.0') _RunDos('netsh interface ip set address name="Wireless Network Connection" gateway=192.168.1.1 gwmetric=0') _RunDos('netsh interface ip set dns name="Wireless Network Connection" source=static addr=194.74.65.68') _RunDos('netsh interface ip add dns name = "Wireless Network Connection" addr = 194.74.65.69') I use that to change the ip address of the computer. I then want to test the connection to make sure it is connected. I want it to ping the router to make sure their is a connection, but if it dosent get a reply after 20 seconds i want it to give up and close the program. Link to comment Share on other sites More sharing options...
_Chris_ Posted September 13, 2006 Author Share Posted September 13, 2006 RIGHT... Ive made a few developments, i need to look at the error code, the error code must be 2 (host unreachable) for it to close the program. I still REALLY need a way of running a ping for 20 seconds. May be i could run a small ping (e.g. with a 250 milisecond time out) but run it 50 times, thus giving the system time to get its new address. I would also like to put in a cancel button to stop it pinging Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 13, 2006 Moderators Share Posted September 13, 2006 Just use a while loop like i did above and change the Ping out. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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