Results 1 to 4 of 4

Thread: How Sleep command work on Batch file in Windows

  1. #1
    Join Date
    Apr 2008
    Posts
    242

    How Sleep command work on Batch file in Windows

    When writing a batch file to automate something on a Windows box, I've needed to pause its execution for several seconds and for that i have decided to keep those file on Sleep mode, how it will work under Sleep Mode please let me know.

  2. #2
    Join Date
    Oct 2008
    Posts
    127

    Re: How Sleep command work on Batch file in Windows

    Most operating systems provide a command in batch files to sleep, or wait, a certain number of seconds. This is great in that batch files can display text, allowing you time to read before continuing. If you have Python installed, or don't mind installing it (it has other uses too) , just create the following sleep.py script and add it somewhere in your PATH:

    import time, sys

    time.sleep(float(sys.argv[1]))

    In XP, you can edit it in:

    My Computer → Properties (menu) → Advanced (tab) → Environment Variables (button) → System variables (frame)

  3. #3
    Join Date
    Feb 2006
    Posts
    331

    Re: How Sleep command work on Batch file in Windows

    Sleep.bat is a Windows batch program that pauses your batch file for temporary before continuing. Sleep.exe is included in most DOS resource kits. If that is the case, that's the best idea. If you don't have it, it's easily found on the Internet (I added it to my Windows XP). I assume of course that you can add executable to your box. The easiest solution in Windows XP / 2003 environment is to install Windows Server 2003 Resource Kit Tools. This tool kit will install the Sleep.exe program into your machine, which you can use as

    SLEEP n

    to sleep for N sec. If you want to sleep for just a few milliseconds u can use this command as

    SLEEP –M n

  4. #4
    Join Date
    Jan 2009
    Posts
    163

    Re: How Sleep command work on Batch file in Windows

    The Resource Kit has always included this. At least since Windows 2000. Sleep.bat uses the "ping.exe" program to emulate the sleep function. The "ping.exe" program is distributed with most versions of Windows operating system.

    Sleep.bat takes advantage of the SetNumberOfArguments.bat (GPL) script that is available on this web site. So to use Sleep.bat, you'll have to download SetNumberOfArguments.bat, if you don't already have it.

Similar Threads

  1. FTP Upload batch file doesn't work properly in Task Scheduler
    By supphavith09 in forum Windows Server Help
    Replies: 1
    Last Post: 09-02-2012, 07:39 AM
  2. How to work with if command and batch file
    By kolton in forum Operating Systems
    Replies: 5
    Last Post: 01-12-2010, 12:09 AM
  3. stringtokenizer in batch file / dos command
    By sayeed in forum Software Development
    Replies: 2
    Last Post: 14-10-2009, 01:26 PM
  4. Can We check the exit command in the batch file
    By Dhruv in forum Software Development
    Replies: 3
    Last Post: 30-12-2008, 11:56 PM
  5. Replies: 1
    Last Post: 18-03-2007, 12:22 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,101,515.13499 seconds with 16 queries