Alternative to using wscript.sleep in a hta

Posted on 2009-04-16
Last Modified: 2012-05-06
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?
Question by:Simon336697
    LVL 7

    Accepted Solution

    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 "wait.vbs 250", 0, true

    Make sure the HTA and script are in the same directory.
    LVL 1

    Author Comment

    Thanks sj appreciate it :>)
    LVL 65

    Assisted Solution

    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

    LVL 1

    Author Comment

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

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
    Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now