Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop problem

Status
Not open for further replies.

NetNodeMan

Technical User
Mar 30, 2005
65
IE
I have the following problem when running the code below:

The code runs and opens a web page. It will then enter some data on that page and if successful will open up a new page. The problem is as follows:

If the test is successful the explorer page closes. If the test is unsuccessful (timeout) a new command shell pops up and runs the code again. If the webpage is unavailable a new command shell opens and it closes the old one. The problem is that even on a time out the test may be successful. This means that the log gets a "Test OK" message but a new command shell opens. How can I close the command shell and open a new one while at the same time having an error message on a timeout?

Option explicit

Dim IE, sLoop, sLoop2, isOperationComplete, dState, sList, sError

Sub objIE_NavigateError(pDisp,URL,TargetFrameName,StatusCode,Cancel)
wscript.echo now() & " Error " & StatusCode & " accessing " & URL
ieErr=true
End Sub


Function Wait()
sError = 1
Do while IE.busy
wscript.sleep 1000
sError = sError + 1
Loop
if sError > 20 then
exit Function
end if
dState = IE.document.readystate

while (dState <> "complete" and sError < 20)
Wscript.sleep 1000
dState = IE.document.readystate
sError = sError + 1
wend
if ieErr then 'navigation error
logfile.writeline now() & " Document failed to load. Please Investigate."
wshshell.run "c:\ringin.bat"
wshshell.popup "Document failed to load. Please Investigate",15
createobject("wscript.shell").run "test.bat"
ie.quit

end if
end function




dim wshshell, fso, logfile, slog
dim ieErr : ieErr=false 'global scope added 20/07/05



slog="c:\log\test.txt" 'your input
set wshshell=createobject("wscript.shell")
set fso=createobject("scripting.filesystemobject")

sLoop = "forever"

dState = ""
Do while sLoop = "forever"
sLoop2 = "forever"
Do while sLoop2 = "forever"
set logfile=fso.opentextfile(slog,8,true)


'************ HTTPS Check

set IE=Wscript.CreateObject("InternetExplorer.Application","objIE_")
IE.Navigate(" IE.visible = True
wait()



'Added by Finner, 8 Jul 2005. Populates the correct fields.
IE.document.getElementByID("VRM").value = "QWERTY" 'this is the VRM field
'IE.document.getElementByID("V5RefNo").value = "1" 'this is the V5 field
IE.document.getElementByID("TestNumber").value = "11111111111" 'this is the Test Number field

IE.document.getElementByID("cmdSubmit").click

wait()

if sError <= 50 then
wscript.echo now() & " Test OK"
logfile.writeline now() & " Test OK"
logfile.close
ie.quit
exit do
else

wscript.echo now() & " Test FAILURE"
logfile.writeline now() & " Test FAILURE"
wshshell.run "c:\ringin.bat"
logfile.writeline now() & " Document Experienced Difficulty While Loading. Please Investigate."
wshshell.popup "Document failed to load. Please Investigate",15
createobject("wscript.shell").run "test.bat"
logfile.close
ie.quit

end if
exit do

'************ End of HTTPS Check

sLoop2 = "done"
Loop
'Wait for 15 Minutes
Wscript.Sleep 900000
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top