I want to add time delay in my batch file. The batch file will be running silently at backgorund. Please help me.
- windows XP, windows 7, Vista both 64 and 32 bitUllan– Ullan2012-02-10 15:10:08 +00:00CommentedFeb 10, 2012 at 15:10
- It is hard to help you without more information. What batch language? What have you tried so far? What system? How long of a delay?All of these items are necessary to provide a good answer.Mei– Mei2012-02-10 15:10:50 +00:00CommentedFeb 10, 2012 at 15:10
- Seewindows batch: sleep.Dmitry Shkuropatsky– Dmitry Shkuropatsky2012-02-10 15:11:08 +00:00CommentedFeb 10, 2012 at 15:11
- Just I want to use a DOS commands to run a batch file at the backgorund. The OS I am going to use XP,Vista and Win7. Expecting dleay is amay be about 3-10 seconds. I tried the batch with out delay, but its not deleting a folder since that is used by another application. so I have to wait for few seconds for the exitUllan– Ullan2012-02-10 15:15:23 +00:00CommentedFeb 10, 2012 at 15:15
- The ping command popping up the command prompt.. the batch should run at back end.. can we hide the command prompt..Ullan– Ullan2012-02-10 15:16:59 +00:00CommentedFeb 10, 2012 at 15:16
4 Answers4
timeout 5
to delay
timeout 5 >nul
to delay without asking you to press any key to cancel
2 Comments
/nobreak option. Also note thattimeout cannot run in background.ping localhost -n (your time) >nulexample
@echo offtitle Testecho hiping localhost -n 3 >nul && :: will wait 3 seconds before going next command (it will not display)echo bye! && :: still wont be any spaces (just below the hi command)ping localhost -n 2 >nul && :: will wait 2 seconds before going to next command (it will not display)@exitComments
You want to use timeout.
timeout 10will sleep 10 seconds
3 Comments
>nul timeout 10Ok, yup you use thetimeout command to sleep. But to do the whole process silently, it's not possible with cmd/batch. One of the ways is to create aVBScript that will run theBatch File without opening/showing any window.And here is the script:
Set WshShell = CreateObject("WScript.Shell")WshShell.Run chr(34) & "PATH OF BATCH FILE WITH QUOTATION MARKS" & Chr(34), 0Set WshShell = NothingCopy and paste the above code on notepad and save it asAnyname.**vbs**An example of the *"PATH OF BATCH FILE WITH QUOTATION MARKS" * might be: "C:\ExampleFolder\MyBatchFile.bat"
Comments
Explore related questions
See similar questions with these tags.





