Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm going to write a batch script in windows server 2008. The script is a general windows commands and it needs waiting for few minutes before executing the next line of the script somewhere in the middle. When I tried sleep, it said command not found. Is the command replaced with some other command or if not, how could I install it.

share|improve this question

5 Answers 5

up vote 4 down vote accepted

Sleep.exe is just an executable from the W2K3 RK, no install is required. I don't see why it wouldn't work on W2K8. Download and extract the W2K3 RK, copy sleep.exe to the W2K8 server, add it to system path environment variable, and put it in your batch file.

http://www.microsoft.com/downloads/en/details.aspx?familyid=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en

share|improve this answer
    
Will it work if extract w2k3 RK in w2k8? –  user53864 Dec 24 '10 at 2:02
    
I don't see why not, but you'll have to try it to make sure. –  joeqwerty Dec 24 '10 at 4:50
    
I'll definitely try this –  user53864 Jan 3 '11 at 6:19

In Windows Server 2008 R2, the command to be used is "timeout" which replaces "sleep"

C:\Windows\System32\timeout.exe /T 10 /nobreak

share|improve this answer
    
Could you give some examples that how to use timeout? –  user53864 Feb 24 '11 at 1:29

Move to the preferred scripting language for Win2K8 which is Powershell. The Start-Sleep cmdlet will do just what you are looking for.

share|improve this answer
    
I heard It's possible in powershell but don't know how I could call powershell in batch file. –  user53864 Jan 3 '11 at 6:20
    
Just call the Batch with "& NAMEOFBATCHFILE" (without quotes) –  patricks Jan 18 '11 at 7:10

As workaround you can make an ping -n 60 localhost (its not exactly a minute but you can guess how long) or you create an small vbs and call it with cscript sleep.vbs

wscript.sleep dauer

As far as i know there is no sleep command within the windows series. Only thing is powershell where sleep is supported.

share|improve this answer
    
It may be possible as you said with @ping -30 127.0.0.1 in the batch and I should try this –  user53864 Jan 3 '11 at 6:22
    
Sorry!. The command is ping -n <no in seconds> 127.0.0.1>nul –  user53864 Jan 12 '11 at 5:10
    
It works!. Thanks! –  user53864 Jan 12 '11 at 5:11

timeout is the correct command in windows server 2008 and windows 7 You can get help by typing timeout /? on the command prompt If you would like to use ping then try this ping -w 5000 -n 1 1.0.0.0 This will wait appromiate 5 seconds

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.