• 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
Loop
Wscript.Echo objExec.StdOut.ReadAll()

Ref for above is:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/may06/hey0519.mspx

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?
0
Simon336697
Asked:
Simon336697
  • 2
2 Solutions
 
sj_hicksCommented:
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.
0
 
Simon336697Author Commented:
Thanks sj appreciate it :>)
0
 
RobSampsonCommented:
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...

Regards,

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

Open in new window

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

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