carriecelery Posted November 12, 2010 Share Posted November 12, 2010 I sometimes use a VPN connection. For the past few months, the VPN mini-port will stop passing traffic every couple hours. I've verified this problem from several different computers. The problem is on their end, or something in between. As soon as i disconnect and reconnect the VPN mini-port, service is restored. After reconnection, i open a CMD prompt and run ping -t www.google.com (or some other site) so that i will know when the connection fizzles out again. So, here's what i want to do: I think i need to write a script that will ping a remote location every few seconds and display the relay times in a log-like format similar to a CMD prompt. If several pings in a row fail, it needs to disconnect the VPN, reconnect, and begin pinging again. The biggest problem i've got is i don't know how to make the log-like interface. Obviously a simple MSGBOX isn't going to work. What could i use to make the log? I realize i might be going about this entirely the wrong way, so i appreciate any advice. Link to comment Share on other sites More sharing options...
carriecelery Posted November 12, 2010 Author Share Posted November 12, 2010 (edited) $fail = Int(0) $cycle = Int(0) $var1 = String("www.ask.com,www.bing.com,www.facebook.com,www.google.com,www.hotbot.com,www.lycos.com,www.myspace.com,www.yahoo.com,www.youtube.com,END") $array = StringSplit($var1, ',') While $fail < Int($array[0]-Int(1)) $cycle = Int($cycle + Int(1)) If $array[$cycle] = String("END") Then $cycle = Int(1) EndIf $host = Ping($array[$cycle]) If $host Then Msgbox(0,"Host: #" & $cycle, $array[$cycle] & " - " & $host & "ms") $fail = Int(0) Else Msgbox(0,"Host: #" & $cycle, $array[$cycle] & " - fail " & @error) $fail = Int($fail + Int(1)) EndIf WEnd Msgbox(0,"Error", $fail & " failures in a row.") Edited November 12, 2010 by carriecelery Link to comment Share on other sites More sharing options...
GEOSoft Posted November 12, 2010 Share Posted November 12, 2010 Now that's doing some simple tasks the hard way. You don't need the String()s or the Int()s and it could be handled easier in a For/Next loop instead of the While/WEnd. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
carriecelery Posted August 4, 2011 Author Share Posted August 4, 2011 I solved the problem with my VPN failing to pass traffic by cancelling my wireless internet and getting back on DSL. Then the only issue i had was that my VPN connection would occasionally disconnect. Perhaps once every few days. I have my VPN connection set to attempt to reconnect up to 99 times every 30 seconds. So then all i needed was something to prevent transfers while my VPN connection was disconnected. This is the script i came up with. It has been working flawlessly for several months for me, but i realize it is probably poorly written. I would welcome any advice. expandcollapse popup;This script requires: a Windows XP VPN connection named "VPN" ;This script requires: "C:\Program Files\uTorrent\uTorrent.exe" While 1 If WinExists("VPN Status","Connected") Then Sleep(1000) ElseIf WinExists("Network Connections","Link to VPN failed.") Then _close_uTorrent() WinWaitClose("Network Connections","Link to VPN failed.","",60) Sleep(1000) ElseIf WinExists("Error connecting to VPN") Then _close_uTorrent() WinWaitClose("Error connecting to VPN","",60) Sleep(1000) ElseIf WinExists("Connect VPN") Then _close_uTorrent() WinWaitClose("Connect VPN","",60) Sleep(1000) ElseIf WinExists("Connecting VPN...") Then _close_uTorrent() WinWaitClose("Connecting VPN...","",60) Sleep(1000) Else Run("c:\windows\system32\rundll32.exe c:\windows\system32\shell32.dll,Control_RunDLL c:\windows\system32\ncpa.cpl") WinWait("Network Connections","",4) IF WinExists("Network Connections") Then BlockInput(1) WinActivate("Network Connections") WinWaitActive("Network Connections","",4) If WinActive("Network Connections") Then Send("v{enter}") WinWaitNotActive("Network Connections","",4) If WinActive("Network Connections") Then BlockInput(0) _close_uTorrent() MsgBox(0,"VPN","There seems to have been a problem finding the VPN connection.",60) Exit EndIf WinClose("Network Connections") WinWaitClose("Network Connections","",4) If WinExists("Connect VPN") Then _close_uTorrent() WinActivate("Connect VPN") WinWaitActive("Connect VPN","",4) If WinActive("Connect VPN") Then Send("!c") WinWait("Connecting VPN...","",4) BlockInput(0) WinWaitClose("Connecting VPN...","",60) If WinExists("Connecting VPN...")Then BlockInput(1) WinActivate("Connecting VPN...") WinWaitActive("Connecting VPN...","",4) If WinActive("Connecting VPN...") Then Send("{space}") WinWaitClose("Connecting VPN...","",4) EndIf EndIf EndIf EndIf If WinExists("VPN Status") Then WinActivate("VPN Status") WinWaitActive("VPN Status","",4) If WinActive("VPN Status") Then WinMove("VPN Status","",909,561,367,450,1) If ProcessExists("uTorrent.exe") Then ;Run("c:\progra~1\utorrent\utorrent.exe");For Win XP x86 Run("c:\progra~2\utorrent\utorrent.exe");For Win XP x64 Else ;Run("c:\progra~1\utorrent\utorrent.exe");For Win XP x86 Run("c:\progra~2\utorrent\utorrent.exe");For Win XP x64 ProcessWait("uTorrent.exe",60) ;Run("c:\progra~1\utorrent\utorrent.exe");For Win XP x86 Run("c:\progra~2\utorrent\utorrent.exe");For Win XP x64 EndIf EndIf EndIf EndIf BlockInput(0) EndIf EndIf WEnd Func _close_uTorrent() If ProcessExists("uTorrent.exe") Then ProcessClose("uTorrent.exe") ProcessWaitClose("uTorrent.exe",60) EndIf EndFunc Link to comment Share on other sites More sharing options...
GEOSoft Posted August 4, 2011 Share Posted August 4, 2011 That makes sense to me. Wireless connects are often a poor choice. Just last week I added a 4 port wireless print server to my system. All worked fine the first day but the next day one printer started messing up print jobs and I had to move it back to a USB port on the system. The other 3 seem to be holding out just fine so far but I'm watching them closely. Another thing you will find with any wireless hardware connection is certain features will be missing. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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