Solved

bat script for Win XP, How can I sleep the process

Posted on 2009-03-30
3
492 Views
Last Modified: 2012-05-06
Hi,

See my bat file for XP

@ECHO OFF
:start
test.exe
sleep 300
goto start

I want to set delay of 5 min (300s), but it is throwing the error
"'sleep' is not recognized as an internal or external command"
In Linux I can use sleep, what is the equivalent in Win XP and Win 2003 server.
Basicaly I want to execute the test.exe in every 5 min.
0
Comment
Question by:spectrumsofttech
3 Comments
 
LVL 28

Expert Comment

by:TextReport
ID: 24016696
0
 
LVL 19

Expert Comment

by:PeteJThomas
ID: 24017070
Can you not just remove the sleep line and then schedule the bat file to run every 5 mins? Or is that not an option?
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
ID: 24019630
The traditional approach for a sleep is, as found in many posts here, to use a ping on localhost. It does not consume CPU, and needs no other resources:

@ECHO OFF
:start
test.exe
ping -n 301 127.0.0.1 >nul
goto start

You need to use 301 as ping starts a ping, waits a second, than pings again ... To build a fence with n segments, you need n+1 poles ;-).

A variant would be to use the timeout of ping with a non-existent target:

ping -n 1 -w 300 1.1

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DOSBox Keyboard 3 72
MS DOS script or .Net Script to rename a list of sub-folders 7 105
Create a specific short cut with a parameter. 2 190
How do I delete 2 43
The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

23 Experts available now in Live!

Get 1:1 Help Now