Here is a simple way to automate logging into a website using VBscript.
'Begin program by calling the Main function.
'Create Internet Explorer Application Object
Set IE = WScript.CreateObject("InternetExplorer.Application")
'Set the created objects visibility to true
'You will see Internet explorer open
'If you do not want to see Internet Explorer open then set this to False
IE.Visible = True
'Navigate to the login page
'Wait for page to finish loading
'Populate credentials and hit the submit button
'You will need to view the source of the login page you would like to
'automate logging into. View the source to get the ID values for the username
'input box and password input box.
.getElementByID("css-input-id-goes-here").value = "username"
.getElementByID("css-input-id-goes-here").value = "password"
'Or Call Call IE.getElementByID("css-input-id-goes-here").Click()
'Wait for the web page to load before continuing
Loop While IE.ReadyState < 4 And IE.Busy
First create a Sub called Wait that takes one parameter. This Wait Sub will wait for the page to load before continuing. Now, create a function called Main. This function will navigate to the login form and populate the username, password, and hit the submit button.
The Main function starts by navigating to the login page. In the script replace the "http://www.somedomain.com/somloginpage.com"; with your specified login page you would like to automate logging into. The function then calls the Wait Sub with the IE application object as the parameter. The Wait Sub waits for the page to fully load before the script continues to entering the page credentials.
To automate entering the page credentials you will need to get the source code of the web page. You can get the source code in IE by right clicking on the webpage and selecting "View source". In the source code you will need to find the ID for the username input field and password input field. Once you have obtained these IDs place them in-between the specified .getElementById()s.
The button is accessed by using an index of the form elements. For example, my original index was a (3) because is was the third clickable element in the form. So, you may need to replace the X with a (0) or (1). Optionally you could get the ID of the button and use the .getElementById("ID").click().
Simple way to automate logging into a website using VBscript.
Contact me if you have any questions, comments, or concerns.