Hét vraag- en antwoordplatform van Nederland

Hoe kan je in een .bat bestand een pauze aanbrengen van 5 seconden tussen de commando's?

Ik gebruik sleep -m 500 maar dat commando wordt niet herkend op Windows Vista.

Ik heb dit:
@echo off
start "Firefox" "E:\Program Files\Kantoorprogramma-s\Firefox Browser\firefox.exe"
sleep -m 500
start volgende commando...


Iemand ideeën?

Verwijderde gebruiker
14 jaar geleden
Geef jouw antwoord
0 / 2500
Geef Antwoord

Het beste antwoord

Gebruik timeout:

timeout /T n

Hierbij is n het aantal seconden dat er gewacht moet worden. In jouw geval zou het dus als volgt moeten:

timeout /T 5

De verwerking van je batchbestand zou dan 5 seconden moeten wachten.

Toegevoegd na 3 minuten:
Ik vond deze uitleg nog:

'Use the "timeout" command to make a Vista batch file wait

Another new command in in Vista is "timeout". It will cause the command processor to wait for a specified number of seconds or until a key is pressed. The format is

timeout /T n

where n is the number of seconds to wait. To make the command ignore any key presses, the switch /nobreak can be added:

timeout /T n /nobreak

Because the command gives output listing the time remaining, it may be necessary to use a redirect to nul.

timeout /T n > nul'
rose
14 jaar geleden

Andere antwoorden (2)

Standaard gaat dat niet in Windows (tenzij ze er in Windows 7 iets voor hebben gemaakt dat ik niet ken).

Je zult een extern programmaatje moeten neerzetten, en dat programmaatje moeten aanroepen vanuit je batch-bestand.

Zulke programmaatjes zijn wel te vinden. Meestal heten ze iets met 'pause', 'wait' of 'sleep' in de naam.

Toegevoegd na 7 minuten:
 
Ik heb even rondgezocht. Kijk eens in onderstaande Bron, en zoek naar DelayExec - dat zou wel eens kunnen zijn wat je nodig hebt.
Cryofiel
14 jaar geleden
Deze is wel creatief. Een niet bestaand IP-nummer pingen om tijd te winnen:


@ECHO OFF
:: Use local environment
SETLOCAL

:: Check if a timeout period is specified
IF [%1]==[] GOTO Syntax

:: Filter out slashes, they make the IF command crash
ECHO.%1 | FIND "/" >NUL
IF NOT ERRORLEVEL 1 GOTO Syntax

:: Check if specified timeout period is within limits
IF %1 LSS 1 GOTO Syntax
IF %1 GTR 3600 GOTO Syntax

:: Check for a non-existent IP address
:: Note: this causes a small extra delay!
IF NOT DEFINED NonExist SET NonExist=10.255.255.254
PING %NonExist% -n 1 -w 100 2>NUL | FIND "TTL=" >NUL
IF NOT ERRORLEVEL 1 (
SET NonExist=1.1.1.1
PING 1.1.1.1 -n 1 -w 100 2>NUL | FIND "TTL=" >NUL
IF NOT ERRORLEVEL 1 GOTO NoNonExist
)

:: Use PING time-outs to create the delay
PING %NonExist% -n 1 -w %1000 2>NUL | FIND "TTL=" >NUL

:: Show online help on errors
IF NOT ERRORLEVEL 1 GOTO NoNonExist

:: Done
GOTO End

:NoNonExist
ECHO.
ECHO This batch file needs an invalid IP address to function
ECHO correctly.
ECHO Please specify an invalid IP address in an environment
ECHO variable named NonExist and run this batch file again.

:Syntax
ECHO.
ECHO PMSleep.bat
ECHO Poor Man's SLEEP utility, Version 2.11 for Windows NT 4 / 2000 / XP
ECHO Wait for a specified number of seconds.
ECHO.
ECHO Usage: CALL PMSLEEP nn
ECHO.
ECHO Where: nn is the number of seconds to wait
ECHO nn can range from 1 to 3600
ECHO.
ECHO Note: Due to "overhead" the actual delay may
ECHO prove to be up to a second longer
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
ECHO Corrected and improved by Todd Renzema, Greg Hassler and Joe Christl
14 jaar geleden
Deel jouw antwoord
0 / 2500
Geef Antwoord
logo van Kompas Publishing

GoeieVraag.nl is onderdeel van Kompas Publishing