phillip123adams Posted January 14, 2008 Posted January 14, 2008 This script restarts a Westell C90-610030-06 DSL single port Router in order to obtain a new IP. Of course, a new IP is obtained only if your IP is dynamic (not static). For other routers, revise the URL and FORM name before compiling (see the comments in the script). In the rare event when the new IP happens to be the same as the old, the script will restart the modem until a new IP is obtained. This script will work with any version of AutoIt3 that provides IE.au3 and INET.au3 user defined functions. expandcollapse popup;; Restart-Westell-C90-Router.au3 ;; Restart a Westel C90-610030-06 DSL Router in order to obtain a new IP. ;; (the IP must be dynamic, not static) ;; ;; Author: Phillip123Adams ;; Date: January 11, 2008 ;; Type: Freeware, no warranty or guarantee. ;; AutoIt version: 3.2.10.0 (freeware from: http://www.autoitscript.com/autoit3/) ;; ;; Note 1a: ;; This AutoIt3 script uses "http://192.168.1.254/restartModemBS.htm?menu=0" ;; to restart the router. Your router may require a different url. To ;; determine your router's URL, open a Windows Command Prompt window and issue ;; the Windows IPCONFIG commnad. Type the number listed for "Default Gateway" ;; into a browser address bar and see where it takes you. Then go to "Note 1b" below. ;; ;; Note 2a: ;; Your router page may use a different name for the "form" containing the ;; button that causes the router to be restarted. The name of the button for ;; the Westell C90 is "backupForm". You'll have to examine your router page to ;; find the name to use. To do that, right click on the page and click view ;; page source to view the html code in your text editor. Search for "<form" ;; (without the quotes), then search for "name=" (without the quotes), ;; and that will be the name to use. Then go to "Note 2b" below. #Region #AutoIt3Wrapper_outfile=Restart-Westell-C90-Router.exe #EndRegion ;; Files in the AutoIt3\Include directory that will be included in the compiled script. #include <IE.au3> #include <Inet.au3> ;; Get the current IP $sIP0 = _GetIP() $iCnt0 = 0 While 1 $iCnt0 = $iCnt0 + 1 ;; It takes about 45 seconds or so for the router to restart. ;; While it does, display a splash screen. SplashTextOn("Restarting C90 Router", "Restarting the Westell C90 Router to obtain a new IP." &@LF& "The Power light will turn red (others off), then green," &@LF& "others will flicker and glow green," &@LF& " and finally the Internet light will glow green again." &@LF& "(This usually takes approximately 45 seconds)" &@LF& "Attempt #" & $iCnt0, 450, 125, -1, -1, 16) ;; ================================================================================ ;; Open the C90 router web page that contains the restart confirmation ;; button titled "yes, restart device". ;; Note: The following statement opens the page without displaying it. If ;; you would prefer to see it, change the last zero to 1. ;; ;; Note 1b: Adjust the url in the following line to suit your router. This is the ;; url containing the button that actually restarts the router. (see note 1a above) $oIE = _IECreate ("http://192.168.1.254/restartModemBS.htm?menu=0", 0, 0) ;; ================================================================================ ;; ================================================================================ ;; Obtain the object name for the form named "backupForm" ;; Note 2b: Change the name "backupForm" to suit the form name on your page (see note 2a above). $oForm = _IEFormGetObjByName ($oIE, "backupForm") ;; ================================================================================ ;; Submit the form, which is the same as pressing the "yes, restart device" button. _IEFormSubmit ($oForm) ;; Wait until the router powers down, loosing the current IP. Should the ;; IP not change after 20 seconds, break out of the loop. $sIP1 = _GetIP() $iCnt1 = 0 While $sIP1 = $sIP0 And $iCnt1 < 20 Sleep(1000) ;; Check the IP again. $sIP1 = _GetIP() $iCnt1 = $iCnt1 + 1 WEnd ;; Wait until the router restarts and an IP is returned. Sleep(1000) $sIP1 = _GetIP() While $sIP1 = -1 Sleep(1000) ;; Check the IP again $sIP1 = _GetIP() WEnd SplashOff() ;; Close the IE window (which may be hidden). _IEQuit ($oIE) ;; Check that the new IP is different than the original IP. ;; If so, exit the loop. If not, try again. If $sIP1 <> $sIP0 then ExitLoop ;; The IP was not changed, so try again. MsgBox(4096, "The IP Did Not Change", "The IP did not change during attempt #" & $iCnt0 & ". Will try again after a 10 second delay.", 10) WEnd ;; All is well, the IP has been changed. ;; Display a message that will time out after 10 seconds, ;; giving the router a little extra time to settle down. MsgBox(4096, "The IP has been reset", "The new IP is ___ : " & $sIP1 &@LF& "The original IP was: " & $sIP0 &@LF&@LF& "(Pausing 10 seconds)", 10) ;; Close this script. Exit Phillip
HCPHN Posted November 10, 2010 Posted November 10, 2010 Very nice! You tested and working? On a DHCP or PPPOE network? Verizon DSL? I hacked the script and tried on my Westell A90 (Verizon DSL, DHCP, Dynamic IP) and it did not work I am really needing a script that can do this, any suggestions? Thanks, Harry This script restarts a Westell C90-610030-06 DSL single port Router in order to obtain a new IP. Of course, a new IP is obtained only if your IP is dynamic (not static). For other routers, revise the URL and FORM name before compiling (see the comments in the script). In the rare event when the new IP happens to be the same as the old, the script will restart the modem until a new IP is obtained. This script will work with any version of AutoIt3 that provides IE.au3 and INET.au3 user defined functions. expandcollapse popup;; Restart-Westell-C90-Router.au3 ;; Restart a Westel C90-610030-06 DSL Router in order to obtain a new IP. ;; (the IP must be dynamic, not static) ;; ;; Author: Phillip123Adams ;; Date: January 11, 2008 ;; Type: Freeware, no warranty or guarantee. ;; AutoIt version: 3.2.10.0 (freeware from: http://www.autoitscript.com/autoit3/) ;; ;; Note 1a: ;; This AutoIt3 script uses "http://192.168.1.254/restartModemBS.htm?menu=0" ;; to restart the router. Your router may require a different url. To ;; determine your router's URL, open a Windows Command Prompt window and issue ;; the Windows IPCONFIG commnad. Type the number listed for "Default Gateway" ;; into a browser address bar and see where it takes you. Then go to "Note 1b" below. ;; ;; Note 2a: ;; Your router page may use a different name for the "form" containing the ;; button that causes the router to be restarted. The name of the button for ;; the Westell C90 is "backupForm". You'll have to examine your router page to ;; find the name to use. To do that, right click on the page and click view ;; page source to view the html code in your text editor. Search for "<form" ;; (without the quotes), then search for "name=" (without the quotes), ;; and that will be the name to use. Then go to "Note 2b" below. #Region #AutoIt3Wrapper_outfile=Restart-Westell-C90-Router.exe #EndRegion ;; Files in the AutoIt3\Include directory that will be included in the compiled script. #include <IE.au3> #include <Inet.au3> ;; Get the current IP $sIP0 = _GetIP() $iCnt0 = 0 While 1 $iCnt0 = $iCnt0 + 1 ;; It takes about 45 seconds or so for the router to restart. ;; While it does, display a splash screen. SplashTextOn("Restarting C90 Router", "Restarting the Westell C90 Router to obtain a new IP." &@LF& "The Power light will turn red (others off), then green," &@LF& "others will flicker and glow green," &@LF& " and finally the Internet light will glow green again." &@LF& "(This usually takes approximately 45 seconds)" &@LF& "Attempt #" & $iCnt0, 450, 125, -1, -1, 16) ;; ================================================================================ ;; Open the C90 router web page that contains the restart confirmation ;; button titled "yes, restart device". ;; Note: The following statement opens the page without displaying it. If ;; you would prefer to see it, change the last zero to 1. ;; ;; Note 1b: Adjust the url in the following line to suit your router. This is the ;; url containing the button that actually restarts the router. (see note 1a above) $oIE = _IECreate ("http://192.168.1.254/restartModemBS.htm?menu=0", 0, 0) ;; ================================================================================ ;; ================================================================================ ;; Obtain the object name for the form named "backupForm" ;; Note 2b: Change the name "backupForm" to suit the form name on your page (see note 2a above). $oForm = _IEFormGetObjByName ($oIE, "backupForm") ;; ================================================================================ ;; Submit the form, which is the same as pressing the "yes, restart device" button. _IEFormSubmit ($oForm) ;; Wait until the router powers down, loosing the current IP. Should the ;; IP not change after 20 seconds, break out of the loop. $sIP1 = _GetIP() $iCnt1 = 0 While $sIP1 = $sIP0 And $iCnt1 < 20 Sleep(1000) ;; Check the IP again. $sIP1 = _GetIP() $iCnt1 = $iCnt1 + 1 WEnd ;; Wait until the router restarts and an IP is returned. Sleep(1000) $sIP1 = _GetIP() While $sIP1 = -1 Sleep(1000) ;; Check the IP again $sIP1 = _GetIP() WEnd SplashOff() ;; Close the IE window (which may be hidden). _IEQuit ($oIE) ;; Check that the new IP is different than the original IP. ;; If so, exit the loop. If not, try again. If $sIP1 <> $sIP0 then ExitLoop ;; The IP was not changed, so try again. MsgBox(4096, "The IP Did Not Change", "The IP did not change during attempt #" & $iCnt0 & ". Will try again after a 10 second delay.", 10) WEnd ;; All is well, the IP has been changed. ;; Display a message that will time out after 10 seconds, ;; giving the router a little extra time to settle down. MsgBox(4096, "The IP has been reset", "The new IP is ___ : " & $sIP1 &@LF& "The original IP was: " & $sIP0 &@LF&@LF& "(Pausing 10 seconds)", 10) ;; Close this script. Exit
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