Skip to content

Instantly share code, notes, and snippets.

@hnakamur
Created July 28, 2013 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hnakamur/6099140 to your computer and use it in GitHub Desktop.
Save hnakamur/6099140 to your computer and use it in GitHub Desktop.
VBScript to open and login to the AWS console with IE.
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()
@hnakamur
Copy link
Author

Run with

cscript ie_aws_console.vbs "_YOUR_USER_ID_HERE_" "_YOUR_PASSWORD_HERE_"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment