How to login website with username and password using windows (XP) batch script

batch-file, command-line, windows-xp

Solution

With batch I can't think of a way. With VBScript, it's easy. Create a new text file and name it AutomateIE.vbs and add the following code. Double click it to run it.

Set IE = CreateObject("InternetExplorer.Application")
IE.navigate "http://TheWebsite"
IE.Visible = True

While IE.Busy
    WScript.Sleep 50
Wend

Set ipf = IE.document.all.username
ipf.Value = "Username" 
Set ipf = IE.document.all.password
ipf.Value = "Password" 
Set ipf = IE.document.all.Submit
ipf.Click 
IE.Quit

Make sure username and password are the actual names defined in the website or it won't work. Change them to whatever they should be. If you post the URL, I can verify them.

Problem

I am able to connect website using batch file but I don't know how to insert username & password into it and of course a click on submit button. Also i would like to know how to click buttons available on sites (ex. export in xls option) using windows batch script. Thanks in advance.

Original source