I'm currently opening a local url from batch command (.bat file) like this:

@echo off
start /d "C:\Program Files\Internet Explorer" IEXPLORE.EXE http://some_local_address:88

This is working fine.
The first thing that this site does is to ask for a username and password in a popup window. Is it possible to pass this information (or at least username) from the .bat file itself, so it is auto-completed in the emerging login window?

(Note that I'm aware you can complete username and password the first time, and "remember credentials", I just want to know if this is possible to pass from command line and how).

  • The only way I know of is to pass it through the URL (e.g. user:password@site.com) if the site uses basic auth, but this is disabled by default in newer versions of IE/edge. Beyond that I think you're in saved password / add-on territory – BrianC Mar 16 '16 at 0:05
  • If you can get your batch file to send keystrokes I don't see why not. Depending on how the page is setup I would imagine you could open the page, send Tab until the cursor is in the username box, send the username, send Tab again, send the password, send Enter. – root Mar 16 '16 at 16:18
  • You may be able to use curl.exe, which allows certain fields to be set. Otherwise, there is the Selenium add-on for Firefox, but you won't easily be able to control this from a batch file. – AFH Mar 16 '16 at 18:53
  • @BrianC, that is no longer supported. – zed Mar 17 '16 at 14:09
  • @root, any example on how to do that? – zed Mar 17 '16 at 14:11

I don't think this can be done using a batch file as batch has its own limitations, instead you can you the below VB script.

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

While IE.Busy
    WScript.Sleep 50

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

Update Website name, uname and passwd and then save this as AutoWebsite.vbs

  • Thank you. This does not work since the login is not an html form, but a windows prompt instead, which opens up when you hit the website. – zed Mar 17 '16 at 13:58
  • I don't understand windows prompt. – manjesh23 Mar 17 '16 at 15:00
  • Sorry, I mean that the login is a little window that pops up asking for username and password, which is not an html form but a browser window instead. – zed Mar 17 '16 at 15:09
  • Use curl: stackoverflow.com/questions/2594880/… – pbies Jul 17 '17 at 18:22
  • I used this but i am unable to login. – Myanju Feb 9 '18 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.