web-dev-qa-db-fra.com

Commande Sleep / Wait en lot

Je veux ajouter un délai dans mon fichier de commandes. Le fichier de commandes s'exécutera en mode silencieux à backgorund. Aidez-moi, s'il vous plaît.

11
Ullan

timeout 5

retarder

timeout 5 >nul

pour retarder sans vous demander d'appuyer sur une touche pour annuler

23
The Moo
ping localhost -n (your time) >nul

exemple

@echo off
title Test
echo hi
ping localhost -n 3 >nul && :: will wait 3 seconds before going next command (it will not display)
echo bye! && :: still wont be any spaces (just below the hi command)
ping localhost -n 2 >nul && :: will wait 2 seconds before going to next command (it will not display)
@exit
5
Itsproinc

Vous souhaitez utiliser le délai d'expiration. timeout 10 dormira 10 secondes

3
fiestacasey

Ok, vous utilisez la commande timeout pour dormir. Mais pour faire tout le processus en silence, ce n'est pas possible avec cmd/batch. L'une des façons est de créer un VBScript qui exécutera le fichier batch sans ouvrir/afficher aucune fenêtre. Et voici le script:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "PATH OF BATCH FILE WITH QUOTATION MARKS" & Chr(34), 0
Set WshShell = Nothing

Copiez et collez le code ci-dessus sur le bloc-notes et enregistrez-le sous Anyname . ** vbs ** Un exemple de * " CHEMIN DU FICHIER DE LOT AVEC DES MARQUES DE CITATION "* peut être:" C:\ExampleFolder\MyBatchFile.bat "

0
Student Seng