none
Vbs script to open a website, auto input user Id and password RRS feed

  • Question

  • By reading few website, tried the below vbs code and I am unsuccessful.

    It opens website but does not pick the name,

    DIM IE
    DIM ipf

    Set IE = CreateObject("InternetExplorer.Application")
    IE.navigate "

    https:
    //bsa.
    bomag.
    com/default/

    "

    IE.Visible = True

    While IE.Busy
         WScript.Sleep 50
    Wend

    Set ipf = IE.document.all.getElementByID("Username")
    ipf.Value = "redmond" 'fill in the text box
    'Set ipf = IE.document.all.state
    'ipf.Value = "WA" 'fill in the text box
    'Set ipf = IE.document.all.Submit
    'ipf.Click    'click the submit button
    'IE.Quit

    Requesting to review my website and correct my code, so that on click it can website.

    regards


    • Edited by Alam For Vbs Monday, December 24, 2018 5:37 PM
    • Moved by Bill_Stewart Monday, July 29, 2019 8:02 PM Abandoned
    Monday, December 24, 2018 5:34 PM

All replies

  • Why are you attempting to do this in a dead language?

    Here is an example of how you could do this in PowerShell, though really I wouldn't be using COM, instead, using invoke-webrequest or similiar.

    function waitFor-Ie {while ($IE.busy) {sleep -milliseconds 10; Write-Progress "Waiting for IE..."}}
    function Start-Over {Get-Process -Name iexplore | Stop-Process; cls; $IE = $null}
     
    Start-Over
     
    $IE= new-object -com InternetExplorer.Application
    $IE.navigate2(“http://social.technet.microsoft.com/Profile")
    waitFor-Ie
    $IE.visible=$true
     
    #In chrome, right-click something and select 'inspect element' to get element  
     $SearchBoxElement = $IE.Document.getElementById("SearchTextBox")
    $SearchButtonElement = $IE.Document.getElementById("SearchButton")
    waitFor-Ie
     
    $SearchBoxElement.focus() 
    $SearchBoxElement.value = "Pizza"
    waitFor-Ie
    $SearchButtonElement.click()
    Write-Host "Done"



    Mike Crowley

    My Blog | MikeCrowley.US

    Baseline Technologies | Baseline.Consulting

    Being ignorant is not so much a shame, as being unwilling to learn

    -Ben Franklin

    • Proposed as answer by Mike Crowley Wednesday, December 26, 2018 6:14 PM
    Monday, December 24, 2018 5:59 PM
  • Sir,

    Thanks for your reply.

    I am still on Windows 7, where I don't find while searching Power shell.

    Secondly no knowledge on this power shell coding.

    Little familiar with VBA and Vbs, therefore, was trying to achieve my requirement through it.

    Please advice, any help you can do on vbs to complete my requirement.

    regards

    Tuesday, December 25, 2018 5:19 AM
  • Windows 7 includes PowerShell (so did Vista). If you're familiar with VBS, the above sample should be a pretty good bridge to PowerShell for you.


    Mike Crowley

    My Blog | MikeCrowley.US

    Baseline Technologies | Baseline.Consulting

    Being ignorant is not so much a shame, as being unwilling to learn

    -Ben Franklin

    Wednesday, December 26, 2018 6:14 PM
  • P.S. - Windows 7 was the first OS to include PowerShell.  PS could be installed on all system from XP on but only W7 and later came with PS.


    \_(ツ)_/

    Wednesday, December 26, 2018 6:31 PM
  • P.S. - Windows 7 was the first OS to include PowerShell.  PS could be installed on all system from XP on but only W7 and later came with PS.


    \_(ツ)_/


    Thanks for keeping me honest. It came with 2008, which is what I was thinking.


    Mike Crowley

    My Blog | MikeCrowley.US

    Baseline Technologies | Baseline.Consulting

    Being ignorant is not so much a shame, as being unwilling to learn

    -Ben Franklin

    Wednesday, December 26, 2018 7:01 PM
  • W7 was released just before WS2008.  They are synced OS versions so they both are the first desktop and server to get W7.  WS2008, Vista and XP no longer exist.  They were removed from support and from most documentation a few years ago.

    WikiPedia keeps a fairly good page on PowerShell releases. 

    PS2 was delivered with W7 but should be upgraded and PS2 should not be used for too many reasons to go into here.


    \_(ツ)_/

    Wednesday, December 26, 2018 7:05 PM
  • I will also point out that the web site referenced does not have an element with ID "username".

    Screen scraping and IE automation is s difficult tasks for anyone who does not know HTML.  Also most modern web sites do not allow automation of logon pages for security reasons.


    \_(ツ)_/

    Wednesday, December 26, 2018 7:12 PM
  • W7 was released just before WS2008.  They are synced OS versions so they both are the first desktop and server to get W7.  WS2008, Vista and XP no longer exist.  They were removed from support and from most documentation a few years ago.

    WikiPedia keeps a fairly good page on PowerShell releases. 

    PS2 was delivered with W7 but should be upgraded and PS2 should not be used for too many reasons to go into here.


    \_(ツ)_/

    You're referring to 2008 R2. 2008 was the "server version" of Vista. Also, I'm not sure what the current support statement has anything to do with anything.



    Mike Crowley

    My Blog | MikeCrowley.US

    Baseline Technologies | Baseline.Consulting

    Being ignorant is not so much a shame, as being unwilling to learn

    -Ben Franklin

    Wednesday, December 26, 2018 7:18 PM
  • Inspection of the site shows that the username input box is a "name" attribute and not an ID.  It is also embedded in multiple framesets and tables so the whole hierarchy must be specified to get to the inputs.

    A login cannot be started with a submit of the document and the embedded form does not use a submit it uses a  "POST" command.

    The page is also an double embedded frameset which makes parsing almost impossible.


    \_(ツ)_/

    Wednesday, December 26, 2018 7:25 PM
  • Yes.  W2008 was first but released shortly after Win7. 

    You can no longer find upgrades for WS2008 for almost any product.  WMF 4 and later are no available for WS2008.

    I only wanted to note that PS is not part of Vista and the unsupported nature means that most fixes and many security patches are not available for those OSs. Neither should be in use for security and stability reasons.

    end-of-life is a critical designation and since the demise of WS2003 MS has been rapidly removing all updates to systems after end-of-life.  I warn anyone trying to use these OSs that they can get deeply boxed into a corner when it comes to recovery.  It is now virtually impossible to install XP because the required service packs are no longer available.  I keep a folder with all necessary patches to install an XP system for use in recovery clients crashed systems. 


    \_(ツ)_/

    Wednesday, December 26, 2018 7:35 PM