Re: WScript.Sleep for HTA?



Hi,

"McKirahan" <News@xxxxxxxxxxxxx> wrote in message
news:rsydnRPA7KjOD8LfRVn-tQ@xxxxxxxxxxxxxx
> "Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
> news:e1bRHUXQFHA.3664@xxxxxxxxxxxxxxxxxxxxxxx
>> > Actually, no; so I'm only sleeping for 1 millisecond
>> > which is fine for my purposes!
>>
>>
>> In that case, this would problably serve your purpose just as well...
>>
>> SH.Run "cmd.exe /c exit"
>>
>> It's the call to Run that matters in this case, not what you run...
>>
>> --
>> Michael Harris
>> Microsoft MVP Scripting
>> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>> Please ask follow-up questions via the original newsgroup thread.
>
>
> It's probably preferable as it doesn't require a file.
>
> Shouldn't "%comspec%" be used instead of "cmd.exe"?
> I often test under PWS on Win98SE which has "command.com".
>
> However ... now that I'vr tested it there's a problem.
> I get a black screen for a 2+ seconds -- bad!!
>
> Here's a test script; any thought?
>
> <html>
> <head>
> <title>Comspec.hta</title>
> <script type="text/vbscript">
> Sub Comspec()
> Dim objWSS
> Set objWSS = CreateObject("WScript.Shell")
> objWSS.Run "%comspec% /c exit",,True
> Set objWSS = Nothing
> End Sub
> </script>
> </head>
> <body>
> <input type="button" value="Comspec()" onclick="Comspec()">
> </body>
> </html>


You can add a screen parameter (0) to hide the black screen.

objWSS.Run "%comspec% /c exit",0,True

I'm puzzled by the 2+ seconds, however - this should just be a quick flash,
even with the screen display. (It is on both my XP and 98 machines).

Dropping the final True seems to give a shorter delay. The script will
delay long enough to run cmd.exe or command.com in either case; it just
won't wait for the command processor to exit.

Regards,
Joe Earnest



.