Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 500
  • Last Modified:

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

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
spectrumsofttech
Asked:
spectrumsofttech
1 Solution
 
TextReportCommented:
0
 
PeteJThomasCommented:
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
 
QlemoC++ DeveloperCommented:
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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now