I am using below VB script for auto login in to website. It is entering username but it does not enter password and gives the error that 'doesn't support this property or method' . I have not worked in VB script , so not sure why this error is coming.
On Error Resume Next
Const PAGE_LOADED = 4
Set objIE = CreateObject("InternetExplorer.Application")
Call objIE.Navigate("http://www.gmail.com")
objIE.Visible = True
Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop
objIE.Document.all.username.Value = "username"
objIE.Document.all.Passwd.Value = "password"
If Err.Number <> 0 Then
msgbox "Error: " & err.Description
End If
Call objIE.Document.all.login_form.submit
Set objIE = Nothing
Try if this code can did the trick or not because gmail has changed its source code !
Dim IE
Set IE = Wscript.CreateObject("InternetExplorer.Application")
IE.Visible = 1
IE.navigate("https://accounts.google.com/ServiceLogin?service=ig&passive=true&continue=http://www.google.com/ig%3Fhl%3Den&followup=http://www.google.com/ig%3Fhl%3Den&cd=US&hl=en&nui=1<mpl=default")
Do While (IE.Busy)
WScript.Sleep 10
Loop
Set Helem = IE.document.getElementById("Email")
Helem.Value = "Your Login goes here" 'Change to your Gmail login
Set Helem = IE.document.Forms(0)
Helem.Submit
Do While (IE.Busy)
WScript.Sleep 10
Loop
wscript.sleep 2000
Set Helem = IE.document.getElementById("Passwd")
Helem.Value = "Your Password goes here" 'Change to your Gmail password
Set Helem = IE.document.Forms(0)
Helem.Submit
Related
I can't figure out how can I fill Login Form with User and Pass and click on "OK" button.
I've tried several variants and nothing has been typed.
I made also I print screen with html code for each form.
On error resume next
Dim WshShell, objIE, ElementCol
Dim LinkHref
LinkHref = "https://www...."
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = False
objIE.Navigate LinkHref
wshShell.AppActivate objIE
Do While objIE.Busy
wscript.sleep 100
Loop
Set ElementCol = objIE.Document.getElementsByTagName("a")
For Each Link In ElementCol
If Link.innerHTML = "Continue to this website (not recommended)." Then
Link.Click
Exit For
End If
Next
objIE.Visible = True
objIE.Document.All.Item("S01LOGIN").value = "myusername"
'objIE.Document.getElementByName("S01LOGIN").Value = "myusername"
'objIE.document.getElementById("S01LOGIN").value = "myusername"
objIE.Document.All.Item("S02PASS").value = "mypass"
'objIE.Document.getElementByName("S02PASS").Value = "mypass"
'objIE.document.getElementById("S02PASS").value = "mypass"
I use IE11 and I think this is the problem
Below is the code block i used to open a new window. I tried using GetObject in place of Create Object as below. But did not work.
Set IE = GetObject("","InternetExplorer.Application")
'
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.navigate "https://msn.com"
Do While IE.ReadyState <> 4
WScript.Sleep 1000
Loop
Set ElementCol = IE.Document.getElementsByTagName("a")
For Each Link In ElementCol
If Link.innerHTML = "News" Then
Link.Click
WScript.Sleep(6000)
Exit For
End If
Next
IE.navigate "https://msn.com"
This uses Explorer which used to do the internet.
Set objShell = CreateObject("Shell.Application")
Do
Set AllWindows = objShell.Windows
Count = 0
For Each window in AllWindows
msgbox window.locationname
' window.refresh2 3
Count = Count + 1
Next
If Count = 0 then Exit Do
Wscript.sleep 5000
Loop
On Error Resume Next:
Const PAGE_LOADED = 4
Set objIE = CreateObject("InternetExplorer.Application")
Call objIE.Navigate("http://172.25.25.32:8090/")
objIE.Visible = True
Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop
objIE.Document.all.Username.Value = "ashishgi"
objIE.Document.all.Password.Value = "apac2015#"
If Err.Number <> 0 Then
msgbox "Error: " & err.Description
End If
Call objIE.Document.all.gaia_loginform.submit
Set objIE = Nothing
The gaia_loginform is the "form id" of Gmail. Have a look here: http://i.imgur.com/45H7pKP.jpg.
Now I think you should get the form name/id of the site (by viewing the source) so that the script can hit the login button.
Hello and thank you in advance for your time.
I am trying to automate a login for a specific site using VBscript. My code works great...up to a point. I execute the script, it opens IE, populates both the username and the password, and then submits. The problem is, after the credentials are submitted, I get an error saying the username and/or password is incorrect. I know 100% both the username and password are in fact correct.
I am quite sure I have located the culprit, however I cannot figure out how I should amend my code to accommodate. A good look at the login screen with firebug revealed a domain was being appended to the username. My code does not reflect this, therefore I get the username/password error after I submit.
Here is my code... and below my code is the JavaScript pulled from the website using firebug:
On Error Resume Next
Const PAGE_LOADED = 4
Set objIE = CreateObject("InternetExplorer.Application")
Call objIE.Navigate("https://snvacaid-bwxsp01.megapathvoice.com/Login/")
objIE.Visible = True
Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) :
Loop
objIE.Document.loginForm.EnteredUserID.Value = "username"
objIE.Document.all.Password.Value = "password"
If Err.Number <> 0 Then
msgbox "Error: " & err.Description
End If
Call objIE.Document.all.loginForm.submit
Set objIE = Nothing
JavaScript from website:
function submitForm() {
//append domain to the userId if it is available and not
//already contained in the userId
var userId = document.loginForm.EnteredUserID.value;
var domain = document.loginForm.domain.value;
document.loginForm.UserID.value = userId;
if ((userId.indexOf("#") == -1) && (domain != "")){
document.loginForm.UserID.value = userId + "#" + domain;
}
document.loginForm.submit();
}
Sorry for taking so long in informing all that I answered my own question; however, below is the solution I came up with and it does work. Thank you for all the replies.
On Error Resume Next
Const PAGE_LOADED = 4
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objIE = CreateObject("InternetExplorer.Application")
Call objIE.Navigate("https://snvacaid-bwxsp01.megapathvoice.com/Login/")
objIE.Visible = True
Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep (100)
Loop
objIE.Document.loginForm.UserID.Value = "username"
objIE.Document.all.Password.Value = "password"
If Err.Number <> 0 Then
msgbox "Error: " & err.Description
End If
Call objIE.Document.all.loginForm.submit
I've got the vbscript below which needs to send a GET request and then logoff the current user. The idea is to replace the default "logoff" start menu item with this script.
When I run it with cscript it throws an error on line 9,
HTTPGet = IE.document.documentelement.outerhtml
I don't understand what's wrong. Maybe I should wait to receive the response before logging off the user, but as the line above doesn't seem to work I logoff immediately.
TOKEN = "xxxxx"
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 0
IE.navigate "https://something.com/?action=create&token=" & TOKEN
Do While IE.Busy
WScript.Sleep 200 ' see the above notice of change
Exit Do ' prevents script host from going crazy waiting for IE
loop
HTTPGet = IE.document.documentelement.outerhtml
IE.quit
Set IE = Nothing
'WScript.Echo HTTPGet 'good for debugging. shows what you got back.
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "C:\WINDOWS\system32\shutdown.exe -l"
If it matters this is for Windows XP only with IE 8.
Try out this code:
Set IE = CreateObject("InternetExplorer.Application")
IE.visible = 0
IE.navigate "https://host/?a=" & TOKEN
i = 1
Do While (IE.readyState <> 4)
WScript.Sleep 1000 ' see the above notice of change
i = i + 1
If (i > 10) Then
Exit Do
End If
loop
HTTPGet = IE.document.documentElement.outerHTML
IE.Quit()
Set IE = Nothing