Created
July 28, 2013 16:14
-
-
Save hnakamur/6099140 to your computer and use it in GitHub Desktop.
VBScript to open and login to the AWS console with IE.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Const HomeUrl = "https://console.aws.amazon.com/console/home?#" | |
' Const LogoutUrl = "https://console.aws.amazon.com/console/logout!doLogout" This URL crashes IE | |
Const LogoutUrl = "https://console.aws.amazon.com/ec2/v2/logout!doLogout" | |
Dim userId | |
Dim password | |
userId = Wscript.Arguments(0) | |
password = Wscript.Arguments(1) | |
Function IE_Start() | |
Dim ie | |
Set ie = CreateObject("InternetExplorer.Application") | |
ie.Visible = True | |
ie.Toolbar = True | |
ie.MenuBar = True | |
ie.AddressBar = True | |
ie.StatusBar = True | |
Set IE_Start = ie | |
End Function | |
Sub IE_WaitLoading(ie) | |
Do While ie.Busy Or ie.readystate <> 4 | |
WScript.Sleep 500 | |
Loop | |
End Sub | |
Sub IE_OpenUrlAndWait(ie, url) | |
ie.Navigate url | |
IE_WaitLoading ie | |
End Sub | |
Dim ie | |
Set ie = IE_Start() | |
IE_OpenUrlAndWait ie, HomeUrl | |
'WScript.Echo "home url loaded." | |
If IsNull(ie.Document.getElementById("ap_email")) Then | |
IE_OpenUrlAndWait ie, LogoutUrl | |
'WScript.Echo "logouted" | |
IE_OpenUrlAndWait ie, HomeUrl | |
'WScript.Echo "login page opened" | |
End If | |
ie.Document.getElementById("ap_email").Value = userId | |
ie.Document.getElementById("ap_password").Value = password | |
ie.Document.getElementById("signInSubmit").Click() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run with