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!

Popup appears, disappears and then closes application

Status
Not open for further replies.

NetNodeMan

Technical User
Mar 30, 2005
65
IE
Hi all. I've tried a search on this and though lots of threads appear, none seem to specifically deal with this request:

I run a batch file called test. This batch files checks an internet page and enters data into the page. If all goes well it writes an "OK" message to a log file. If all goes wrong it provides a popup. This popup does not time out and must be clicked before the program can continue.

What I would like is that if an error occurs, the popup appears but for only 10 minutes. I have tried timing out the popup but this exits my batch file and I have to restart the batch file manually. I do not want to do this. Can anyone help?

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
End Sub



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.popup "Document failed to load. Please Investigate",15 (popup appears but after timeout the batch file closes and I must restart manually - don't want that)
end if
end function




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

slog="c:\log\logfilename.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 = "LD02YXZ" 'this is the VRM field
'IE.document.getElementByID("V5RefNo").value = "1" 'this is the V5 field
IE.document.getElementByID("TestNumber").value = "152008305118" 'this is the Test Number field

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

wait()

if sError <= 20 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"
wshshell.popup " Web Check has Failed. Please Investigate" (Also want the popup to timeout here and continue testing the application)
logfile.close
ie.quit
exit do
end if


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

sLoop2 = "done"
Loop
'Wait for 5 Minutes
Wscript.Sleep 18000
Loop
 
wshshell.popup " Web Check has Failed. Please Investigate", 600 '600=10*60 seconds

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Yeah I understand that. However, after the 10 minutes it will close my application. I want the popup to die and my application to continue.
 
Why have you TWO objIE_NavigateError sub ?
Why you never use set IE = Nothing ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Ignore the TWO obj subs. This is from my test version of the script.

SetIE=Nothing. Will that help fix my problem?
 
I quote my last post to your previous thread.
self said:
[3'] At the place above, instead of checking document.readystate, do this instead.

if ieErr then 'navigation error
logfile.writeline now() & " - " & dState & " - " & "Document failed to completely loaded for unknown reason."
wshshell.popup "Document failed to completely loaded for unknown reason.",15
[red]ieErr=false[/red] 'reset it
end if
end function
I think you do not take enough attention to ieErr=false line.
 
Thanks tjusi but this doesn't work.

This kills the popup after 15 seconds and leaves internet explorer open but does not leave the batch file open. I want the batch file to remain open and continue testing and also close the internet explorer page (which works ok)
 
>does not leave the batch file open
What batch file? Do you mean you have a .bat/.cmd type of file and run a line something like
cscript //nologo that.vbs
After this is called, the batch file will continue to next line. The only trouble is if your batch file is run with %comspec% /c switch, it will close. You have to open up a cmd window and run the batch file or click with %comspec% /k switch. In any case the batch file will come to its end some time by its design.

But if you mean you want the batch to wait eternally for cscript //nologo that.vbs to close (which will not), then somehow you use something like start.exe /w to launch the cscript line.
 
I have a batch file as follows:


@echo off
Title DO NOT CLOSE - Web Check in Progress
cscript webtest.vbs

This runs my .vbs script. Once the test runs ok it writes to the log and then tests again 30 minutes later. If it doesnt run ok, the popup appears. If you click ok on the popup the popup disappears and the batch file closes. I am hoping to have the popup disappear and the batch file remain.
 
What may also work is if I call the original batch file from the .vbs script. Is it possible to launch a batch file from the .vbs script?
 
The batch file would close that way only if your vbs file has runtime error. (Besides my description in above post is not 100% accurate. The batch wait for the cscript line to end before executing the following up, effectively a synchronous operation.)

Try a testing on this.
[tt]
'this is a vbs testing file call it test.vbs, say
'run it on cmd prompt window, host it by cscript
b=true
b2=true
n=0
p=0
do while b
if n<5 then
wscript.echo "outerloop" & vbcrlf & "n=" & n & vbcrlf & "p=" & p
n=n+1
else
b=false
end if
do while b2
p=p+1
'if p>5 then
if p>5000 then
b2=false 'needless but just keep it for a while
exit do
end if
loop
wscript.echo "you're in outerloop end" & vbcrlf & "b=" & b & vbcrlf & "b2=" & b2
b2=true : p=0
wscript.sleep 10000 'also for testing batch synchroneity
createobject("wscript.shell").popup "Please wait...",10
loop
wscript.echo "quit"
[/tt]
Then the batch file test.bat say.
[tt]
::test.bat
@echo off
rem testing synchronization
cscript //nologo s78_test.vbs
echo I am here
[/tt]
It won't execute echo I am here until all the junk is finished. Are you seeing the same?
 
I've actually got this to work by simply calling the batch file again once the popup disappears. Thanks for your valuable input
 
Okay if you are satisfied with that and do not want to get to the bottom of the thing. I suspect you have runtime error somewhere in the vbs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top