Skip to content
Fix Code Error

How to sleep for five seconds in a batch file/cmd

March 13, 2021 by Code Error
Posted By: Anonymous

Windows’s Snipping tool can capture the screen, but sometimes I want to capture the screen after five seconds, such as taking an image being displayed by the webcam. (Run the script and smile at the camera, for example.)

How do I sleep for 5 seconds in a batch file?

Solution

One hack is to (mis)use the ping command:

ping 127.0.0.1 -n 6 > nul

Explanation:

  • ping is a system utility that sends ping requests. ping is available on all versions of Windows.
  • 127.0.0.1 is the IP address of localhost. This IP address is guaranteed to always resolve, be reachable, and immediately respond to pings.
  • -n 6 specifies that there are to be 6 pings. There is a 1s delay between each ping, so for a 5s delay you need to send 6 pings.
  • > nul suppress the output of ping, by redirecting it to nul.
Answered By: Anonymous

Related Articles

  • Simplest way to create Unix-like continuous pipeline…
  • Error 'Map', but got one of type 'Null' flutter web…
  • Error using core-scaffold from polymer JS in the…
  • Could not find androidx.camera:camera-view
  • Android Camera Preview Stretched
  • What are the undocumented features and limitations…
  • Rails wrong number of arguments error when…
  • How many times the loss function is triggered from…
  • How to create an empty file at the command line in Windows?
  • How to make a SIMPLE C++ Makefile
  • How do SO_REUSEADDR and SO_REUSEPORT differ?
  • Android: How to use webcam in emulator?
  • How to check if ping responded or not in a batch file
  • Get operating system info
  • Error: the entity type requires a primary key
  • How can I find the product GUID of an installed MSI setup?
  • How to add Typescript to a Nativescript-Vue project?
  • How to turn on front flash light programmatically in…
  • How to get the system uptime in Windows?
  • Text size and different android screen sizes
  • Unity - Project a texture on a mesh using C# (No Shaders)
  • 'block in draw' rails 6 routes
  • org.springframework.beans.factory.NoSuchBeanDefiniti…
  • How to get work calling methods of embedded Flash…
  • Setting up and using Meld as your git difftool and mergetool
  • Displaying a webcam feed using OpenCV and Python
  • 3D Rotation of a camera using its own, new axes
  • Access IP Camera in Python OpenCV
  • Average values between two dates by group
  • Capturing a single image from my webcam in Java or Python
  • UnboundLocalError: local variable 'event' referenced…
  • C++ OpenGL stb_image.h errors
  • How do I make a Windows batch script completely silent?
  • homals package for Nonlinear PCA in R: Error in dimnames(x)
  • ComboBox.SelectedItem giving Null value
  • Setting Camera Parameters in OpenCV/Python
  • Run chrome in fullscreen mode on Windows
  • Pose detection on two videos simultaneously in a…
  • How to ping an IP address
  • Windows could not start the Apache2 on Local…
  • Batch script: how to check for admin rights
  • Best way to access web camera in Java
  • From inside of a Docker container, how do I connect…
  • How can I programmaticaly copy text from notepad and…
  • Sleeping in a batch file
  • Suppress command line output
  • How to wait in a batch script?
  • How to set Android camera orientation properly?
  • Rotate camera in Three.js with mouse
  • Why am I getting a nil pointer error depending on…
  • Removing double quotes from variables in batch file…
  • Ping with timestamp on Windows CLI
  • Logging best practices
  • ngx-webcam open front camera by default in mobile
  • Capture Image from Camera and Display in Activity
  • how to customize `show processlist` in mysql?
  • Running a cron every 30 seconds
  • Batch files : How to leave the console window open
  • How to convert CMD to JSON array correctly in Dockerfile?
  • How should I deal with "package '✘✘✘' is not…
  • Start redis-server with config file
  • How to read a file and write into a text file?
  • How do I install Java on Mac OSX allowing version switching?
  • What is the reason for the error message "System…
  • An Authentication object was not found in the…
  • How to ping a server only once from within a batch file?
  • Running shell command and capturing the output
  • Can Windows Containers be hosted on linux?
  • Pass data object from parent to child component
  • Issue in loading ember app as child application in…
  • center 3 items on 2 lines
  • Stored procedure or function expects parameter which…
  • Error: container has not been made global - how to solve?
  • Can I mask an input text in a bat file?
  • Remix error The transaction has been reverted to the…
  • Docker compose fails to start a service with an…
  • DateTime vs DateTimeOffset
  • Remove Cesium's Camera Move Event Listener
  • Using aurelia-cli unable to get bootstrap and a…
  • When should one use a spinlock instead of mutex?
  • CMD: Export all the screen content to a text file
  • Homebrew install specific version of formula?
  • Cannot install additional requirements to apache airflow
  • Aurelia bundling issue with virtual directory
  • Oracle listener not running and won't start
  • Find and kill a process in one line using bash and regex
  • BeautifulSoup: extract text from anchor tag
  • What does do?
  • What is your most productive shortcut with Vim?
  • TypeError: Cannot read property 'webpackJsonp' of undefined
  • Failed to load resource: unsupported url
  • How to update Python?
  • Timeout a command in bash without unnecessary delay
  • Runing vue/cli app under docker simple index.html is opened
  • SOLVED | (discord.py) Bot doesn't respond to any…
  • Android splash screen image sizes to fit all devices
  • Python : Using Turtle-graphics, having issue with…
  • ExecuteNonQuery: Connection property has not been…
  • Trying to make a real time object detection with…
  • What is the JavaScript version of sleep()?

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

Next Post:

Parse JSON in JavaScript?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error