sleep or wait in batch files: pause cmd

 

The function wait or sleep was not available in BATch files by default.
Remedy is a small detour via the ping Command

sleep or wait with ping

Command:

@ping -n 10 localhost> nul

 waits in about 10 seconds (-n 10) and then continues to execute the batch file.

retrofit sleep command

sleep.cmd in C:\Windows\System32

@echo off
@ping localhost -n 2 > NUL
@ping localhost -n %1 > NUL

Windows Vista/7/8/10/11

since Windows Vista there is the command:

timeout

timeout /T 10 waits 10 seconds, the waiting time can be skipped with any key, to prevent this there is the parameter: /nobreak
timeout /T 10 /nobreak

further topics

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Publication: 2022-05-02 from Bernhard | Übersetzung Deutsch |🔔 | Comments:0

CMD Commands Overview: BATch Commands Windows Command Prompt | Windows Batch | Robocopy example - server relocation

Top articles in this section


Execute remote commands with psexec pstools - cmd Windows

The pstools can be used to execute commands on other computers: Of course, this requires the necessary rights for the remote connection: by default, these are the domain administrator or the local administrator. As an alternative for a remote connection to another computer, PowerShell remoting can also be used, see: Powershell Remote


Structure of a batch file Syntax: echo off cmd

If you have created a batch file, you can write a command in each line, see: how to create a batch file - basics. The commands are executed in sequence when the file is started. The behavior of the output can be adjusted as follows:


Practical examples with batch

Handling variables in Windows Batch (command prompt) Read all variables Variables can be read out in the command prompt with the set command:

Questions / Comments