Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Snooze a Batch File  (Read 5984 times)

0 Members and 1 Guest are viewing this topic.

powlaz

    Topic Starter


    Beginner
  • Thanked: 1
    Snooze a Batch File
    « on: May 31, 2007, 12:24:56 PM »
    Is there a way to snooze a batch file?  I'd like to put a 60 second delay (for example) into my batch file.
    I don't want to use Ping because I don't want the ping to show in the command window
    I don't want to use Choice because 1.  There is nothing to choose, 2.  I don't want to risk someone hitting the keyboard and accidentally choosing and throwing off the delay.

    I use Windows XP command prompt and am a very novice batch file writer.

    WillyW



      Specialist
    • Thanked: 29
    • Experience: Experienced
    • OS: Windows XP
    Re: Snooze a Batch File
    « Reply #1 on: May 31, 2007, 01:00:47 PM »
    Is there a way to snooze a batch file?  I'd like to put a 60 second delay (for example) into my batch file.
    I don't want to use Ping because I don't want the ping to show in the command window
    I don't want to use Choice because 1.  There is nothing to choose, 2.  I don't want to risk someone hitting the keyboard and accidentally choosing and throwing off the delay.

    I use Windows XP command prompt and am a very novice batch file writer.

    Check out:
    http://www.computerhope.com/forum/index.php/topic,34932.msg212726.html#msg212726

    Not sure about your #2 requirement above -  you'll have to check out the docs/examples... perhaps look at command line switches.

    After you check it out,   post back and let us know if that solved your need -  or if you need some help with it.

    .



    powlaz

      Topic Starter


      Beginner
    • Thanked: 1
      Re: Snooze a Batch File
      « Reply #2 on: May 31, 2007, 01:28:36 PM »
      "Wait" looks good.  I also have one called 'Sleep'.  I was hoping there was a way to do it without calling another program.  That would be ideal but isn't pertinent. 

      WillyW



        Specialist
      • Thanked: 29
      • Experience: Experienced
      • OS: Windows XP
      Re: Snooze a Batch File
      « Reply #3 on: May 31, 2007, 01:34:38 PM »
      "Wait" looks good.  I also have one called 'Sleep'.  I was hoping there was a way to do it without calling another program.  That would be ideal but isn't pertinent. 

      The price of Wait is right -  it's free.   :)      If you don't like it, or figure out something better at a later date,  you are out nothing. 

      You are using XP.   I'm not an XP person.   If there is a way to do it,  maybe someone will be along shortly.    Hang in there.

      This type of question comes up occasionally.   While you are waiting to see if anyone else posts an idea for you,  you might want to try some different searchs of the forums here.   Maybe you'll find something previously discussed that will help you.


      .



      GuruGary



        Adviser
        Re: Snooze a Batch File
        « Reply #4 on: May 31, 2007, 03:42:17 PM »
        I don't want to use Ping because I don't want the ping to show in the command window
        I personally use PING myself when the environment is going to be unknown and you don't know what external programs are going to be available.  You can suppress the PING output by redirecting the output.  For example, to pause for 60 seconds with no output, do:
        Code: [Select]
        @echo off
        echo Sleeping for about 60 seconds ...
        ping -n 61 localhost >NUL
        echo 60 seconds is up.

        powlaz

          Topic Starter


          Beginner
        • Thanked: 1
          Re: Snooze a Batch File
          « Reply #5 on: June 04, 2007, 11:24:19 AM »
          Gary, thanks.  This is what I was looking for.  I like Sleep.exe and Wait.exe but I like the idea of having most of the work done in the batch file done from the batch file.

          I appreciate the help.

          One question:

          You reference "localhost" in the ping line instead of using the actual IP address, right? 
          What does >NUL do?

          OK that was two questions but I think I know the answer to the first one.

          Po

          contrex

          • Guest
          Re: Snooze a Batch File
          « Reply #6 on: June 04, 2007, 11:28:54 AM »
          NUL is the "null device". It swallows console output and renders it invisible. Some programs ignore it, but most command line apps respect it. Ping does.

          Code: [Select]
          c:\>echo hello
          hello

          c:\>echo hello>nul

          c:\>

          Incidentally, a little known property of all existing folders is that they have a nul in them

          Code: [Select]
          c:\>if exist c:\nul echo yes
          yes

          You can use this to tell if a folder exists or not.





          GuruGary



            Adviser
            Re: Snooze a Batch File
            « Reply #7 on: June 05, 2007, 03:20:35 PM »
            One question:
            You reference "localhost" in the ping line instead of using the actual IP address, right? 
            Yes.  I prefer to use "localhost" for my host when use PING to make a program sleep.  On most computers this should be the same as 127.0.0.1 and is defined in the "hosts" file.  This way the ping stays on the local computer and does not create any network traffic, and it is a good control because we know what it is and where it is.