Search code examples
batch-filetimeoutescaping

Timeout command in batch


I want to create a batch file with a timer in it, using another batch file. In the first one I wrote

type NUL > File2.bat

echo Timeout /T 5 /NOBREAK>NUL>> "File1.bat"

A batch file called File1.bat is made, but the "> NUL" is missing. It only contains.

Timeout /T 5 /NOBREAK

Can someone please assist me?


Solution

  • Insert a caret character (^) before the >. This "escapes" the special meaning of the >.

    Best to use a text editor to create batch files. I use editplus ut there are many others, including notepad++.

    Don't use a word-processor, and be very careful if you use notepad (as supplied with windows) as these are aimed more at word-processing and automatically format the file created as a document rather than a simple text file.