Finnerbahce
Technical User
How can i get a vbs script to run for an hour and exit. It's currently running every two minutes but I want it to run every two minutes for one hour.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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
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
' 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 INTERNET EXPLORER PAGE FAILS TO OPEN
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
***********************This is where I want to test this and if the error occurs 5 times then call sendmail.bat
end if
end function
'**************CREATE LOGFILE AND AMEND/APPEND
dim wshshell, fso , slog , logfile
dim ieErr : ieErr=false 'global scope added 20/07/05
slog = "c:\log\Test" & Right("0" & Day(Date), 2) & Right("0" & Month(Date), 2) & Year(Date) & ".log"
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)
'************ HTTP CHECKER
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 = "1234567" 'this is the VRM field
'IE.document.getElementByID("V5RefNo").value = "1" 'this is the V5 field
IE.document.getElementByID("TestNumber").value = "111222333444" '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
***********************This is also where I want to test this and if the error occurs 5 times then call sendmail.bat
end if
exit do
'************ End of HTTPS Check
sLoop2 = "done"
Loop
'Wait for 15 Minutes
Wscript.Sleep 900000
Loop