Saturday, 28 May 2016

Enter Username And Password Using VBscript

Call the Vbscript file using batch file

Batch File :

REM :Start
Pause
call  "C:\Users\sendhil\Desktop\Test\test2.vbs"
Pause

VBscript Code :

WScript.Quit Main

Function Main
  Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
  IE.Visible = True
  IE.Navigate "http://default/Login.aspx"
  Wait IE
  With IE.Document
    .getElementByID("txtusername").value = "admin1"
    .getElementByID("txtpwd").value = "XXXX"
    .getElementsByName("btnok").Item(0).Click


  End With

 
End Function

Sub Wait(IE)
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy
  Do
    WScript.Sleep 500
  Loop While IE.ReadyState < 4 And IE.Busy
End Sub

Sub IE_OnQuit
  On Error Resume Next
  WScript.StdErr.WriteLine "IE closed before script finished."
  WScript.Quit
End Sub

No comments:

Post a Comment