batch-filetimeout

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


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: