Skip to content Skip to sidebar Skip to footer

Automatically Logging In Website Using Vb Script

I am trying to automate login process for a website. I used below code Dim objIE Dim htmld Set objIE = CreateObject('InternetExplorer.Application') objIE.Visible = False objIE.Navi

Solution 1:

Try these additional checks:

Dim IE
Set IE = CreateObject("InternetExplorer.Application")
With IE
    .Visible = False
    .Navigate "website.com"' website.com is example not the originalDoWhile .Busy OrNot .readyState = 4: WScript.Sleep 100: LoopDoUntil .document.readyState = "complete": WScript.Sleep 100: LoopDoWhile TypeName(.document.getElementById("login_id")) = "Null": WScript.Sleep 100: Loop
    .document.getElementById("login_id").Value = "ss"EndWith

Solution 2:

I wrote a vbscript to do just what you asked, and I use it all the time. It opens up one tab in IE, and logs in, then it opens two more tabs to different pages in our application.

OnErrorResumeNext

ECRecord = "http://vm195/views/welcome.action"
ECJobs = "http://vm195/views/job/jobList.action?query.MaxResults=500&allStates=false%2F&query.ActiveState=true&query.ActiveState=false%2F&query.PendingState=true&query.PendingState=false%2F&query.CompletedState=false%2F&query.FailedState=true&query.FailedState=false%2F&query.CancelledState=true&query.CancelledState=false%2F&query.HoldState=true&query.HoldState=false%2F&query.jobTypes=-1&allFreqs=true&allFreqs=false%2F&query.DailyFrequency=true&query.DailyFrequency=false%2F&query.IntervalFrequency=true&query.IntervalFrequency=false%2F&query.SetDateFrequency=true&query.SetDateFrequency=false%2F&query.SingleFrequency=true&query.SingleFrequency=false%2F&query.patientId=&query.accessionNumber=&query.studyPk=&query.dateRange=-3&query.beginDate=&query.endDate=&Submit=Search&refreshRate=120"
ECConfig = "http://vm195/views/org/organizationTree.action"Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True'open a new window
oIE.Navigate2 ECRecord

DoWhile (oIE.Busy)
   WScript.Sleep 10LoopSet Helem = oIE.document.getElementByID("username")
 Helem.Value = "tsu500"' change this to yoursSet Helem = oIE.document.getElementByID("password")
 Helem.Value = "production"' change this to yours

 oIE.Document.getElementsByName("submit_button").Item(0).Click

 'Set Helem = oIE.document.Forms(1)'Helem.Submit


WScript.Sleep 500DoWhile (oIE.Busy)
   WScript.Sleep 10Loop'open url In new tab
oIE.Navigate2 ECJobs, 2048
WScript.Sleep 100
oIE.Navigate2 ECConfig, 2048Set oIE = Nothing

Post a Comment for "Automatically Logging In Website Using Vb Script"