#include <ie.au3>
;Script executes the following steps below to update routers ISP
;1. Enter router IP address in browser
;2. Assumes default admin account used and updates router password only
;3. Sends enter Key
;4. Accesses the "Internet Setup" link via hyperlink
;5. Enables the checkbox under WAN Setup
;6. Clicks the "Edit" button
;7. Updates Username
;8. Updates Password
;9. Clicks "Next" button
;10. Clicks "Apply" button
;11. Clicks "Logout" link
;12. Closes browser session
;Update router IP address
$oIE = _IECreate ("Router IP Address Here")
_IELoadWait($oIE,0)
Sleep(5000)
$HWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($HWND, "", @SW_MAXIMIZE)
_IELoadWait($oIE,0)
Sleep(5000)
$oIECollection = _IEFormGetCollection($oIE, 0)
;Default admin account used. I've just updated the password field. Update code with router password.
$oPasswordField = _IEFormElementGetObjByName($oIECollection, 'password')
_IEFormElementSetValue($oPasswordField, "Router password here")
_IELoadWait($oIE,0)
Sleep(5000)
Send("{ENTER}")
_IELoadWait($oIE,0)
Sleep(5000)
;Update the code below with the hyperlink for "Internet Setup"
_IENavigate($oIE, "Internet Setup Hyperlink here")
Sleep(5000)
$oForm = _IEFormGetObjByName($oIE, 0)
$oCheckbox = _IEFormElementGetObjByName($oForm, "rml");
$oCheckbox.checked = True
_IELoadWait($oIE,0)
Sleep(5000)
$oEditButton = _IEGetObjById($oIE, "editWancfg")
_IEAction($oEditButton, "click")
_IELoadWait($oIE,0)
Sleep(5000)
;Updates the username field. Update code with your ISP Username
$oPPPUsername = _IEGetObjByName($oIE, "pppUserName")
_IEFormElementSetValue($oPPPUsername, "Enter ISP username here")
_IELoadWait($oIE,0)
Sleep(5000)
;Updates the password field. Update code with your ISP Password
$oPPPUsername = _IEGetObjByName($oIE, "pppPassword")
_IEFormElementSetValue($oPPPUsername, "Enter ISP password here")
_IELoadWait($oIE,0)
Sleep(5000)
$oNextButton = _IEGetObjById($oIE, "btnNext")
_IEAction($oNextButton, "click")
_IELoadWait($oIE,0)
Sleep(5000)
$oApplyButton = _IEGetObjByName($oIE, "btnSave")
_IEAction($oApplyButton, "click")
_IELoadWait($oIE,0)
Sleep(40000)
Local $sMyString = "Logout"
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
Local $sLinkText = _IEPropertyGet($oLink, "innerText")
If StringInStr($sLinkText, $sMyString) Then
_IEAction($oLink, "click")
ExitLoop
EndIf
Next
_IELoadWait($oIE,0)
Sleep(10000)
_IEQuit($oIE)