Sleep/Wait Command in Batch [Duplicate]
I Want to Add Time Delay in My Batch File. the Batch File Will Be Running Silently at Backgorund. Please Help Me. 5 4 Answers Timeout 5 to Delay Timeout 5 >Nul...
I want to add time delay in my batch file. The batch file will be running silently at backgorund. Please help me.
timeout 5
to delay
timeout 5 >nul
to delay without asking you to press any key to cancel
You want to use timeout. timeout 10 will sleep 10 seconds
ping localhost -n (your time) >nul
example
@echo off
title Test
echo hi
ping 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)
@exit
Ok, yup you use the timeout command to sleep. But to do the whole process silently, it's not possible with cmd/batch. One of the ways is to create a VBScript that will run the Batch 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), 0
Set WshShell = Nothing
Copy and paste the above code on notepad and save it as Anyname.**vbs ** An example of the *"PATH OF BATCH FILE WITH QUOTATION MARKS" * might be: "C:\ExampleFolder\MyBatchFile.bat"