[BATCH] how to--"sleep" command in Windows XP

Discussion in 'Scripting' started by stayboogy, May 1, 2011.

  1. stayboogy

    stayboogy MDL Addicted

    May 1, 2011
    716
    116
    30
    I didn't see this anywhere so forgive me if this has been posted before...

    download: rktools.exe search @ Microsoft, it's the Windows Server 2003 Resource Tools Kit--sorry not enough posts to post links

    this adds various commands to the windows xp repository from the Windows 2000 and 98 platforms, especially the "sleep" command which comes in handy quite frequently, and for me especially when composing batch files for startup processes so that it doesn't interfere with the already many processes used by windows.

    after install use like so:

    @ echo off
    Sleep 60 #where 60 = 1 minute#
    #then your following commands or the name of your batch file you wish to run#

    there are other ways of doing this by using the "ping" command but this is way simpler and cleaner looking and the download is only 11mb
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. Claysoft65

    Claysoft65 MDL Member

    Sep 4, 2009
    136
    51
    10
    Sure, the ResKit is interesting, but it has to be used "on your own PC"... i mean that if you're going to write a script with the purpose
    to distribute it, you cannot ask the user to D/L and install an 11 MB Pack for running a batch...
    Most of those little "trick" (just to remember to you your other post about 'hstart' ) i think that you could easily manage with an exe of 34 KB :p

    Don't you know NirSoft and its nircmd ?
     
  3. stayboogy

    stayboogy MDL Addicted

    May 1, 2011
    716
    116
    30
    #3 stayboogy, May 1, 2011
    Last edited: May 1, 2011
    (OP)
    i was just sharing how to go about getting the "sleep" command to work, which requires "rktools" since "sleep" is not recognized by XP originally--not saying DOWNLOAD THIS BECAUSE I SAID TO or anything like that, just trying to help.

    the "ping" commands are ugly looking and complicated for the novice, this is easier. plus the "ping" command also goes over by a few milliseconds and even longer sometimes so it is not practical for time sensitive operations, which is why this was shared mainly.

    easier and accurate wins every time in my book.


    here's the ping way if it makes you feel better:

    #substitute the following two lines for "sleep" without "rktools"#
    @ping 1.1.1.1 -n 2 -w 1000 > nul
    #ping nonexisting ip for more accurate timing but this not guaranteed#
    @ping 1.1.1.1 -n %1% -w 1000> nul
    #in milliseconds, 1000 will on average result in 1.5 second delay and are never completely accurate#
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. Claysoft65

    Claysoft65 MDL Member

    Sep 4, 2009
    136
    51
    10
    Dude, i think you have just to be a little more quiet and read what i wrote...:biggrin:
    I cannot read anything related to "ping" into my post... and you ?
    NirCMD 2.52 Here it is what I was talking about, and me too, I was just trying to help...
    Hstart is a nice apps, but is missing a lot of function that could be really useful, sometimes, for a scripter (ex... it doesn't have a sleep
    function...)... and if you just would have "Googled" for NirCmd and given a fast look at its page, you'd have understood what i was saying.

    We all are, in any way, forced to use some external programs, sometimes, to better handle a script or its own execution... and, as you said,
    there are some O.S. that doesn't help us at all in doing that, if we need something more than a ping pause that we don't know how long is it...

    You talked about easy and accurate, and i can just add to those features, the lightweight and a list of possible command options that i'm sure
    i would never be able to use in Batch, and all of that into a single FREE command-line Utility of 34 KB.
    So I'm quite sure that i've been only misunderstood, cause i was just giving a further suggestion, for a proggie that it's not only as easy
    and accurate as you (and we...) need, but it's also eas to manage, if, for example, you want to give to a friend one of your script.

    I really think that it's a "MUST-HAVE" in every %windir% folder, (even if you're not used scripting a lot...) and a valuable information for
    everyone that still doesn't know all the NirSoft Utility and, first of all, NirCmd ...

    CU around
    Clay
     
  5. Compo

    Compo MDL Member

    Mar 29, 2011
    137
    105
    10
    If you needed to run an application with a delay you could see if invoking it with the task scheduler using a trigger of 'At Startup' with 'Delay Task for up to...' works for you too.