Reputation: 33
First off, I'm using Windows 7 64-bit, if it makes a difference. I have a batch file in which I'm using the "timeout" function, written as such:
*code does some things*
timeout /t 100 rem wait for 100 seconds for the above thing to finish
If I do timeout /t 100
in the command line, it waits for 100 seconds as I would expect. However, in the script it gives me the error:
ERROR: Invalid syntax. Default option is not allowed more than '1' time(s).
Type "TIMEOUT /?" for usage.
The instructions for timeout
are /t
for number of seconds to wait, /nobreak
to ignore keypresses, and /?
to display the help message. I'm not sure what syntactical error I'm having, or what "default option is not allowed", especially since it seems to work perfectly fine outside of the batch file.
Upvotes: 3
Views: 8816
Reputation: 1
It turned out I was ending my lines with CRs instead of LFs.
In Notepad++, I replaced all the \r with \n and it now works.
Upvotes: 0
Reputation: 4750
A comment is another command. So if you want it on the same line you need to use the & like this.
timeout /t 100 & rem wait for 100 seconds for the above thing to finish
Upvotes: 2
Reputation: 57262
rem wait for 100 seconds for the above thing to finish
timeout /t 100
You cant's set a comment on the same line as the command.
Upvotes: 4