Guest User

AutoItScriptForSwitchingISP

a guest
Nov 21st, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.59 KB | None | 0 0
  1. #include <ie.au3>
  2.  
  3. ;Script executes the following steps below to update routers ISP
  4. ;1. Enter router IP address in browser
  5. ;2. Assumes default admin account used and updates router password only
  6. ;3. Sends enter Key
  7. ;4. Accesses the "Internet Setup" link via hyperlink
  8. ;5. Enables the checkbox under WAN Setup
  9. ;6. Clicks the "Edit" button
  10. ;7. Updates Username
  11. ;8. Updates Password
  12. ;9. Clicks "Next" button
  13. ;10. Clicks "Apply" button
  14. ;11. Clicks "Logout" link
  15. ;12. Closes browser session
  16.  
  17. $routerIpAddress = "http://10.0.0.2/login.html"
  18. $routerAdminPassword="routerPassword"
  19. $pppUserName="[email protected]"
  20. $pppPassword="ispPassword"
  21.  
  22. $oIE = _IECreate ($routerIpAddress)
  23.  
  24. _IELoadWait($oIE,0)
  25. Sleep(1000)
  26.  
  27. $HWND = _IEPropertyGet($oIE, "hwnd")
  28. WinSetState($HWND, "", @SW_MAXIMIZE)
  29.  
  30. _IELoadWait($oIE,0)
  31. Sleep(100)
  32.  
  33. $oIECollection = _IEFormGetCollection($oIE, 0)
  34.  
  35. $oPasswordField = _IEFormElementGetObjByName($oIECollection, 'password')
  36. _IEFormElementSetValue($oPasswordField, $routerAdminPassword)
  37.  
  38. _IELoadWait($oIE,0)
  39. Sleep(100)
  40.  
  41. Send("{ENTER}")
  42.  
  43. _IELoadWait($oIE,0)
  44. Sleep(500)
  45.  
  46. _IENavigate($oIE, "http://10.0.0.2/setup_wancfg.html")
  47.  
  48. Sleep(500)
  49.  
  50. $oForm = _IEFormGetObjByName($oIE, 0)
  51. $oCheckbox = _IEFormElementGetObjByName($oForm, "rml");
  52. $oCheckbox.checked = True
  53.  
  54. _IELoadWait($oIE,0)
  55. Sleep(100)
  56.  
  57. $oEditButton = _IEGetObjById($oIE, "editWancfg")
  58. _IEAction($oEditButton, "click")
  59.  
  60. _IELoadWait($oIE,0)
  61. Sleep(500)
  62.  
  63. ;Updates the username field. Update code with your ISP Username
  64. $oPPPUsername = _IEGetObjByName($oIE, "pppUserName")
  65. _IEFormElementSetValue($oPPPUsername, $pppUserName)
  66.  
  67. _IELoadWait($oIE,0)
  68. Sleep(100)
  69.  
  70. ;Updates the password field. Update code with your ISP Password
  71. $oPPPUsername = _IEGetObjByName($oIE, "pppPassword")
  72. _IEFormElementSetValue($oPPPUsername, $pppPassword)
  73.  
  74. ;Updates the password Confirm field. Update code with your ISP Password
  75. $oPPPUsername = _IEGetObjByName($oIE, "conpppPass")
  76. _IEFormElementSetValue($oPPPUsername, $pppPassword)
  77.  
  78. _IELoadWait($oIE,0)
  79. Sleep(1000)
  80.  
  81. $oNextButton = _IEGetObjById($oIE, "btnNext")
  82. _IEAction($oNextButton, "click")
  83.  
  84. _IELoadWait($oIE,0)
  85. Sleep(1000)
  86.  
  87. $oApplyButton = _IEGetObjByName($oIE, "btnSave")
  88. _IEAction($oApplyButton, "click")
  89.  
  90. _IELoadWait($oIE,0)
  91. Sleep(10000)
  92.  
  93. Local $sMyString = "Logout"
  94. Local $oLinks = _IELinkGetCollection($oIE)
  95. For $oLink In $oLinks
  96.     Local $sLinkText = _IEPropertyGet($oLink, "innerText")
  97.     If StringInStr($sLinkText, $sMyString) Then
  98.         _IEAction($oLink, "click")
  99.         ExitLoop
  100.     EndIf
  101. Next
  102.  
  103. _IELoadWait($oIE,0)
  104. Sleep(5000)
  105.  
  106.  
  107. _IEQuit($oIE)
Advertisement
Add Comment
Please, Sign In to add comment