Login script works on WinXP but not on Win7 - windows

I have a script which logs in to a website. It works perfectly on IE 8 on Windows XP, but when I try the same script on Windows 7 with IE8 it doesn't work.
Can somebody fix this issue?
WScript.Quit Main
Function Main
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "URL"
Wait IE
IE.Document.form.[username].value = "" 'username
IE.Document.form.[password].value = "" 'Password
IE.Document.form.Submit()
End Function
Sub Wait(IE)
Do
WScript.Sleep 500
Loop While IE.ReadyState <> 4 OR IE.Busy
End SUb
Sub IE_OnQuit
On Error Resume Next
WScript.StdErr.WriteLine "IE closed before script finished."
WScript.Quit
End Sub

Related

VBScript error 80004005 check class in IE Document

I'm trying to set my script to sleep until a class is available in a website.
Set IE = createobject("internetexplorer.application")
strURL = "SomeUrl"
If IsNull(IE.Document.GetElementsByClassName("button")) Then
IE.navigate strURL
Do While (IE.Busy Or IE.ReadyState <> 4)
WScript.Sleep 100
Loop
End If
I've looked the error and it does not specify what is wrong so I have no idea.
"Unspecified Error" Code 80004005 at:
If IsNull(IE.Document.GetElementsByClassName("button")) Then
I've also tried:
Set Button = IE.Document.GetElementsByClassName("button")
If IsNull(Button) Then
IE.navigate strURL
Do While (IE.Busy Or IE.ReadyState <> 4)
WScript.Sleep 100
Loop
Set Button = IE.Document.GetElementsByClassName("buttonp")
End If
Same error. What's the problem?

How I can getelement on a "X" site and show in "Y" site mine

I want to capture just selected elements "Raid Boss Status", but I want capture just the raid boss that I say the name for. Example: I want to capture in this site just: Baium, Antharas and Valakas.
I want to capture just that Boss and save it in a new HTML or text file, and if possible I want separate Deads and Alives, and show the importants boss when Lives sending one warning to me see. When one importante boss respawn send to me one alert.
I had the login working.
WScript.Quit Main
Function Main
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "http://zionweb.l2cr.com/gamecpc6/index.php"
'IE.top = 0
'IE.left = 1370
'IE.Height = 770
'IE.Width = 650
Wait IE
With IE.Document
IE.Document.getElementsByName("username")(0).value = "CHECKBOSS"
IE.Document.getElementsByName("password")(0).value = "123456"
IE.Document.forms(0).submit
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

Check network connection with VBScript

I'm running a web-based slideshow on multiple computer units. I have a VBScript that runs on startup, opens IE and navigates to a specific page in fullscreen mode. Everything works great, as long as there's an internet connection on startup. If there isn't then the page never loads. Is there a way in VBScript to check for a connection every couple minutes until the connection is found, and then continue with the script? Here is the code for your reference:
Option Explicit
Dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
On Error Resume Next
With WScript.CreateObject ("InternetExplorer.Application")
.Navigate "http://www.example.com/slideshow"
.fullscreen = 1
.Visible = 1
WScript.Sleep 10000
End With
On Error Goto 0
Refer to this ==> Loop a function?
Yes, you can do it easily with this code :
Option Explicit
Dim MyLoop,strComputer,objPing,objStatus
MyLoop = True
While MyLoop = True
strComputer = "smtp.gmail.com"
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}!\\").ExecQuery _
("select * from Win32_PingStatus where address = '" & strComputer & "'")
For Each objStatus in objPing
If objStatus.Statuscode = 0 Then
MyLoop = False
Call MyProgram()
wscript.quit
End If
Next
Pause(10) 'To sleep for 10 secondes
Wend
'**********************************************************************************************
Sub Pause(NSeconds)
Wscript.Sleep(NSeconds*1000)
End Sub
'**********************************************************************************************
Sub MyProgram()
Dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
On Error Resume Next
With WScript.CreateObject ("InternetExplorer.Application")
.Navigate "http://www.example.com/slideshow"
.fullscreen = 1
.Visible = 1
WScript.Sleep 10000
End With
On Error Goto 0
End Sub
'**********************************************************************************************
If Hackoo's code doesn't work for you, you can try the following. Not all servers will respond to ping requests but you could just make an HTTP request and see if the server sends a valid response (status = 200).
Function IsSiteReady(strURL)
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", strURL, False
.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"
On Error Resume Next
.Send
If .Status = 200 Then IsSiteReady = True
End With
End Function

vbscript to send GET request using IE error

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

VBScript to Launch a website login

I found this script online, I edited most of it.
It is able to enter username, and password on its down but it is not able to click login.
please help me fix
Here is login forum.
http://desistream.tv/en/index.shtml
Here is Script currently it is in IE but I will need to change it open in Google Chrome.
WScript.Quit Main
Function Main
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "http://desistream.tv/en/index.shtml"
Wait IE
With IE.Document
.getElementByID("login_username").value = "myusername"
.getElementByID("login_password").value = "mypassword"
.getElementByID("form").submit
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
Here is...
Call Main
Function Main
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "http://desistream.tv/en/index.shtml"
Wait IE
With IE.Document
.getElementByID("username").value = "myusername"
.getElementByID("pass").value = "mypassword"
.getElementsByName("frmLogin")(0).Submit
End With
End Function
Sub Wait(IE)
Do
WScript.Sleep 500
Loop While IE.ReadyState < 4 And IE.Busy
End Sub
If you look at the page source, you'll see that the actual <form> tag is called frmLogin, not login.

Resources