Give me a break!
May 17, 2008 5:03 AM
Subscribe
How can I install/use the DOS batch scripting SLEEP command with Vista Ultimate? It does not exist by default. Back while scripting on XP, I used to install the free package "Windows Server 2003 Resource Kit Tools" which came with this command.
So basically, I just want to put a 60 second pause in a loop in a script. I am not looking for CPU intensive work-arounds or solutions involving cygwin.
Thanks.
posted by Slenny to technology (5 comments total)
"I am not looking for CPU intensive work-arounds or solutions involving cygwin."
You'll find it most convenient to compile this using cygwin. Compile it with a static library (oh lord is it big, that's C++ IOStreams for you, port it to C if you need it smaller) and you can use it on non-cygwin equipped machines.
For sixty seconds of sleep, call it like this:
sleep 60000
#include <iostream> #include <cstdlib> #include <windows.h> int badargs(const char* name, const char* arg) { std::cerr << "Usage " << name << " unsigned_integral_milliseconds" << std::endl; if(arg) { std::cerr << "Argument \"" << arg << "\" is not an unsigned integral value" << std::endl; } return 1; } int main(int argc, char** argv) { if(argc != 2) { return badargs(argv[0], 0); } const int BASE = 10; char* p = 0 ; char* s = argv[1]; long int sleepMillis = strtol(s, &p, BASE); if(p == s || sleepMillis < 0 ) { // not unsigned number return badargs(argv[0], s); } // std::cout << "Sleeping for " << sleepMillis << " milliseconds" << std::endl; Sleep(sleepMillis); return 0; }posted by orthogonality at 6:23 AM on May 17, 2008