The correct way to sleep in a batch file is to use the timeout
command, introduced in Windows 2000.
To wait somewhere between 29 and 30 seconds:
timeout /t 30
The timeout would get interrupted if the user hits any key; however, the command also accepts the optional switch /nobreak
, which effectively ignores anything the user may press, except an explicit CTRL-C
:
timeout /t 30 /nobreak
Additionally, if you don’t want the command to print its countdown on the screen, you can redirect its output to NUL
:
timeout /t 30 /nobreak > NUL
Related Posts:
- Difference between xcopy and robocopy
- Bat file to run a .exe at the command prompt
- XCOPY: Overwrite all without prompt in BATCH
- What exactly are DLL files, and how do they work?
- The application was unable to start correctly (0xc000007b)
- What does “@” mean in Windows batch scripts
- Create an empty file on the commandline in windows (like the linux touch command)
- How to solve “The directory is not empty” error when running rmdir command in a batch script?
- How do I create a Batch file to change an exe installer to Win XP SP3 compatibility mode and launch installer
- ‘npm’ is not recognized as internal or external command, operable program or batch file
- The filename, directory name, or volume label syntax is incorrect inside batch
- How can I open Java .class files in a human-readable way?
- Batch script loop
- Opening a remote machine’s Windows C drive
- Why does CreateProcess give error 193 (%1 is not a valid Win32 app)
- Taskkill /f doesn’t kill a process
- How to run PowerShell in CMD
- Bluescreen on windows 10 after using android emulator
- xcopy returns error “Invalid number of parameters” when exclude parameter is set
- While loop in batch
- Curl not recognized as an internal or external command, operable program or batch file
- Redirecting Output from within Batch file
- How to send a simple email from a Windows batch file?
- How can I run a program from a batch file without leaving the console open after the program starts?
- What does /p mean in set /p?
- False ‘Sharing Violation’ Xcopy error message
- batch file from scheduled task returns code 2147942401
- How does the echo command works in batch programming
- In Windows cmd, how do I prompt for user input and use the result in another command?
- CALL command vs. START with /WAIT option
- BAT file to map to network drive without running as admin
- How to install and run the Nmap program through Cygwin in Windows?
- Need auto-restart script in batch for minecraft server
- How to use random in BATCH script?
- Windows batch – concatenate multiple text files into one
- How to set commands output as a variable in a batch file
- Batch command for ImageMagick to convert all files in a directory and sub-directories on windows
- How to compile C program on command line using MinGW?
- Best practice for exiting batch file?
- how to empty recyclebin through command prompt?
- All links in my site start with localhost?
- WordPress database setup Windows 2016 IIS
- How do you find what process is holding a file open in Windows?
- How do I tell Git for Windows where to find my private RSA key?
- How to send ctrl+alt+del using Remote Desktop?
- What’s the command-line utility in Windows to do a reverse DNS look-up?
- Useful Command-line Commands on Windows
- How do you add a Windows environment variable without rebooting?
- hosts file ignored, how to troubleshoot?
- How to refresh hosts file without rebooting
- Resolve host name from IP address
- Run a .bat file in a scheduled task without a window
- Command line to list users in a Windows Active Directory group?
- What is Active Directory Domain Services and how does it work?
- Is there a global, persistent CMD history?
- How do I diff two text files in Windows Powershell?
- In Windows, using the command line, how do you check if a remote port is open?
- Does Windows have a built-in ZIP command for the command line?
- Can you run Docker natively on the new Windows 10 (Ubuntu) bash userspace?
- How does CTRL-ALT-DEL to log in make Windows more secure?
- How to check if a port is blocked on a Windows machine?
- How do I force sync the time on Windows Workstation or Server?
- How do I create a symbolic link in Windows?
- Best practice: Should I always install a fresh OS for new employees?
- How can I tell what version of IIS is installed?
- Where can I find data stored by a Windows Service running as “Local System Account”?
- How can I connect to a Windows server using a Command Line Interface? (CLI)
- Windows server last reboot time
- Windows Active Directory naming best practices?
- Why hasn’t rsync caught on in the Windows world? [closed]
- Boot and Install Windows from a USB thumb drive
- How to fix PuTTY showing garbled characters? [closed]
- How to delete cached temporarily credentials for a network share on a Windows machine without rebooting or logging off [duplicate]
- How do you free up a port being held open by dead process?
- What is the Windows equivalent of Unix “whoami” command?
- How to configure a Windows machine to allow file sharing with a DNS alias
- Alternatives to Splunk?
- outputting ascii table in C++
- Tensorflow import error: No module named ‘tensorflow’
- A fatal error occurred while creating a TLS client credential. The internal error state is 10013
- How can I install pip on Windows?
- bash: npm: command not found?
- Windows 7 exception code: 0xc0000409
- What languages are Windows, Mac OS X and Linux written in?
- stop all instances of node.js server
- Windows Activator .bat Text
- “rm -rf” equivalent for Windows?
- VC++ fatal error LNK1168: cannot open filename.exe for writing
- How to stop Python closing immediately when executed in Microsoft Windows
- How Should I Set Default Python Version In Windows?
- How to change current working directory using a batch file
- What exactly is the scope of Access Violation ‘0xc0000005’?
- Open File in Another Directory (Python)
- How to use/install GNU binutils (objdump)
- Why doesn’t WP_PLUGIN_DIR definition use DIRECTORY_SEPARATOR?
- wordpress http to https windows server
- One-click WP site generation wih wp-cli on Windows
- WAMP SERVER Command Prompt SET PATH=%PATH%
- Perfmon performance counters on WAMP
- What’s the reverse DNS command line utility?