Batch command to open url and fulfill username and password

41,869

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
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

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

Share:
41,869

Related videos on Youtube

zed
Author by

zed

Web application development

Updated on September 18, 2022

Comments

  • zed
    zed over 1 year

    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).

    • BrianC
      BrianC about 8 years
      The only way I know of is to pass it through the URL (e.g. user:[email protected]) 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
    • root
      root about 8 years
      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.
    • AFH
      AFH about 8 years
      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.
    • zed
      zed about 8 years
      @BrianC, that is no longer supported.
    • zed
      zed about 8 years
      @root, any example on how to do that?
    • zed
      zed about 8 years
      @AFH, any sample on curl? Can't use addons because the idea of this is to have a portable batch which could run from differents computers on the LAN
    • AFH
      AFH about 8 years
      There are plenty examples on the web if you search for "auto login with curl", including this video.
  • zed
    zed about 8 years
    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.
  • manjesh23
    manjesh23 about 8 years
    I don't understand windows prompt.
  • zed
    zed about 8 years
    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.
  • pbies
    pbies almost 7 years
  • Myanju
    Myanju about 6 years
    I used this but i am unable to login.