• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1455
  • Last Modified:

Alternative to using wscript.sleep in a hta

Hi guys,
Im trying to eliminate the visiblity of a dos command window when running a dsquery from a hta.

With non-hta vbscript, is this true below?

Do Until objExec.Status
    Wscript.Sleep 250
Wscript.Echo objExec.StdOut.ReadAll()

Ref for above is:

Im just wondering if this waits until the command line tool is complete, and then returns results, then is there something comparable for htas? That is, something that would do the same as:

    Wscript.Sleep 250

Without having to use wscript, which you cant use in a hta?
  • 2
2 Solutions
Hi Simon, seeing you've posted an new question about this (and I'm procastinating doing other work), here's one thing you could do.  Other people may come up with a better idea.

1)  Create a new script (vbs, not HTA). Let's call it wait.vbs
2)  Configure the script to accept a command line parameter, which is the wait period, then execute WScript.Sleep <value from command line parameter>
3)  In your HTA, change WScript.Sleep 250 with WshShell.run "wait.vbs 250", 0, true

Make sure the HTA and script are in the same directory.
Simon336697Author Commented:
Thanks sj appreciate it :>)
G'day Simon.

You can also use the function I created, called HTASleep, which just sends a ping to the local machine for a specified amount of seconds.  It's not as precise as WScript.Sleep, but it does the job...


' instead of WScript.Sleep, use HTASleep #, eg:
HTASleep 1
Sub HTASleep(intSeconds)
	Set objShell = CreateObject("WScript.Shell")
	objShell.Run "ping -n " & intSeconds + 1, 0, True
End Sub

Open in new window

Simon336697Author Commented:
Hi sj and Rob,
Guys both champs thank you :>)

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now