From: "Michael Harris (MVP)" <mikhar at mvps dot on
jmosow(a)yahoo.com wrote:
> Here is the HTA I am working on. I think the article you linked to
> about updating the display is taken care of using the Sleep function I
> wrote. The problem I am having is if I close the window using the X
> in the upper-right corner. The mshta.exe continues to run. If I use
> the End button, the mshta will quit.

Here's a simpler example to follow that illustrates the points I was trying
to make. It assumes you have sleep.exe from the w2k or winxp reskit
installed.

Save and run it as a *.hta ...

<html>
<head>
<script language="vbscript">
dim gBusy
sub demo()
gBusy = true
set shell = createobject("wscript.shell")
msg.innertext = "running..."
shell.run "sleep.exe 60",7,true
msg.innertext = "finished..."
gBusy = false
end sub
sub checkBusy()
if gBusy then
window.event.returnValue = "Still busy..."
end if
end sub
</script>
</head>
<body onbeforeunload="call checkBusy()">
<div style="width:50%;font:x-small verdana;">
<p>Click 'demo' to execute sleep.exe 60 in a minimized window
<nobr>(shell.run "sleep.exe 60",7,true)...</nobr>
<p>Click 'close' to within 60 seconds to trigger the onbeforeload
warning.
<p>Notice that the call to shell.run lets the UI refresh and
also lets you click the close button even though the demo event
handler is still running (waiting for shell.run to return).
<p>Also notice that if you cancel the window.close, the modality
of the of shell.run call is broken as well, i.e. as soon as
the window.close is canceled, execution of the demo event handler
resumes immediately after the shell.run call even though
</div>
<hr>
<input type="button" onclick="call demo()" value="demo">
<input type="button" onclick="window.close" value="close">
<hr>
<div id="msg">
</div>
</body>
</html>





--
Michael Harris
Microsoft MVP Scripting
http://maps.google.com/maps?q=Sammamish%20WA%20US


From: jmosow on
Thanks for the sample. My HTA does something similar. I do have an
END button. If I click the END button, the mshta will terminate.
However, if I do an 'abnormal' terminate of the HTA by just closing the
window, the mshta is orphaned. I have not been able to determine how
to get around this.

From: dieseyer.de on
Hallo!

<Alt-F4> close hta-window - 'mshta-engine', but it don't stop, when a
permanent Do..Loop is running.

Put your Do..Loop in a procedure (without Do..Loop) and call this:

YesIntervall = window.setInterval( "EveryTime",1000 )

Example: http://dieseyer.de/scr-html/120minReboot.hta

"jmosow(a)yahoo.com" wrote:

> Thanks for the sample. My HTA does something similar. I do have an
> END button. If I click the END button, the mshta will terminate.
> However, if I do an 'abnormal' terminate of the HTA by just closing the
> window, the mshta is orphaned. I have not been able to determine how
> to get around this.
>
>
First  |  Prev  | 
Pages: 1 2
Prev: Outlook Express and VBScripts
Next: Scripting Printers