Timeout in a batch file

darbo
darbo used Ask the Experts™
on
I am writing a batch file to stop and start services on an NT Server. I want to pause for about ten seconds after I stop it in the batch file to ensure that it has enough time to stop before the batch file tries to start it again. Any ideas???
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
If you don't have any RK tool, just use :

ping -n 11 127.0.0.1 >NUL
Most Valuable Expert 2018
Distinguished Expert 2018
Commented:
An absolute pause is not necessarily long enough.
If you're using the "net start" and "net stop" command, there's no need for it anyway; those commands give the control back only after they're finished.
If you're using sc.exe, which returns immediately, you'll need to query the status of the service and wait until it's properly shutdown.
What is your current situation (and do you have the Resource Kit)?

Commented:
Use the Timeout.exe command from the Win2k Resource Kit... it will do what you want
Top Expert 2007

Commented:
You can certainly schedule net stop/net start using the AT command as well, if it is to be used at the same time.   Otherwise, RK contains SOON which will schedule the job out for a few seconds to several minutes, if that's what you're looking for (although I don't find that this works very well across timezones).

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial