0

I have the below script but it does not sleep before executing the software.

Any ideas?

@echo off
SLEEP 10
START "" "C:\Program Files (x86)\..." 
squidg
  • 317
  • 2
  • 6
  • 20

2 Answers2

5

There are (at least) the following options, as others already stated:

  1. To use the timeout command:

    rem // Allow a key-press to abort the wait; `/T` can be omitted:
    timeout /T 5
    timeout 5
    rem // Do not allow a key-press to abort the wait:
    timeout /T 5 /NOBREAK
    rem // Suppress the message `Waiting for ? seconds, press a key to continue ...`:
    timeout /T 5 /NOBREAK > nul
    

    Caveats:

    • timeout actually counts second multiples, therefore the wait time is actually something from 4 to 5 seconds. This is particularly annoying and disturbing for short wait times.
    • You cannot use timeout in a block of code whose input is redirected, because it aborts immediately, throwing the error message ERROR: Input redirection is not supported, exiting the process immediately.. Hence timeout /T 5 < nul fails.
  2. To use the ping command:

    rem /* The IP address 127.0.0.1 (home) always exists;
    rem    the standard ping interval is 1 second; so you need to do
    rem    one more ping attempt than you want intervals to elapse: */
    ping 127.0.0.1 -n 6 > nul
    

    This is the only reliable way to guarantee the minimum wait time. Redirection is no problem.

aschipfl
  • 28,946
  • 10
  • 45
  • 77
  • in powershell nul does not work - use $null instead. eg. ping 127.0.0.1 -n 6 > $null – wami May 22 '20 at 05:55
0

Try the timeout command.

timeout /t 10

This shows Waiting for 10 seconds, press a key to continue ...

You can use the /nobreak switch that ignores user input (other than CTRL-C)

timeout /t 30 /nobreak

Or you can redirect its output to NUL for a blank screen that waits 10 seconds and ignores user input:

timeout /t 30 /nobreak > NUL