2

I am using Windows 2002 version. I have a batch file to run on this version but there is output the following error on execution of the command timeout /t 35:

'timeout' is not recognized as an internal or external command, operable program or batch file

My code:

ECHO Start Firefox Starts
start /B "" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" imacros://run/?m="login-google-adwords.iim"
timeout /t 35

SS64 documentation of TIMEOUT.exe.

What can I use to as delay for several seconds?

Mofi
  • 46,139
  • 17
  • 80
  • 143
Penny
  • 824
  • 1
  • 14
  • 31
  • Note the linked documentation is for Windows 7/2008 (and XP, which may work in Windows Server 2003, *via the linked resource kit*). Also, there is no "Windows 2002".. – user2864740 Dec 11 '14 at 05:54
  • Yes i got that hence understood it does not support. So, which cmd can i use in order to put delay – Penny Dec 11 '14 at 05:57
  • 1
    @Penny - read the page you linked to: "Alternative - A delay can also be produced by the PING command with a loopback address..." – Michael Burr Dec 11 '14 at 06:01
  • Or download the Windows 2003 Resource Kit and use the `sleep` command it contains: http://go.microsoft.com/fwlink/?LinkId=4544 – Michael Burr Dec 11 '14 at 06:03
  • 1
    Do you have waitfor or choice, they both can act as timers. Plus there is a couple of others that can do timeouts as well. – BambiLongGone Dec 11 '14 at 06:16
  • PING command is not efficacious ! :( – Penny Dec 11 '14 at 06:30
  • It's a really bad idea to use ping. It's just programming wrong. Ping is not a documented timeout command, nor meant to be one. – BambiLongGone Dec 11 '14 at 07:32
  • What exactly do you mean by 'not efficacious'? As far as I can tell it works effectively. If you don't like it because it's not clear or whatever, there are plenty of other options that can be found with a little searching, including the one I linked to just after the `ping` suggestion. One *huge* advantage of using `ping` is that it's already on every Windows machine out there, so you won't have to worry about the problem that prompted you to post this question in the first place. – Michael Burr Dec 11 '14 at 08:31
  • 1
    Choice is also on every machine. – BambiLongGone Dec 11 '14 at 11:16

4 Answers4

4

In server 2008. both the timeout and the ping are located in C:\Windows\System32

So your timeout command will work if you make it C:\windows\system32\timeout /t 5 /NOBREAK

0

The ping timeout uses very little CPU and works fine.

Try this:

ping -4 -n 35 "">nul
foxidrive
  • 40,353
  • 10
  • 53
  • 68
0

If you don't like the suggestion to use ping because it's ugly, consider adding the following to the end of your batch file:

@goto :eof
:timeout
:: use ping to delay for the number of seconds passed as an argument

@ping -n %1 127.0.0.1 > nul
@ping -n 2 127.0.0.1 > nul
@goto :eof

Then in your batchfile you can do things like

call :timeout 10

to delay for the specified number of seconds.

Michael Burr
  • 333,147
  • 50
  • 533
  • 760
0

I recently went through this. It turned out that I set a system variable %Path%. Create another batch file with echo test timeout /t 10

and see the result. I also made a batch called timeout.bat and it repeated the echo without stopping. I have found that many commands can't be in the title and you can not set system variables without consequence.

  • A batch file used by many users should be always coded as fail-safe and secure as possible which means there is used `%SystemRoot%\System32\timeout.exe` instead of just `timeout`. The usage of fully qualified file names of every executable or batch file referenced in a batch file makes the batch file processing independent on much too often corrupted environment variable `PATH`. The batch file is additionally processed a lot faster by the *Windows Command Processor* because of lots of file system accesses for finding the executable/script are avoided too. – Mofi Aug 07 '23 at 16:46
  • Readers should look also on [What is the reason for "X is not recognized as an internal or external command, operable program or batch file"?](https://stackoverflow.com/a/41461002/3074564) – Mofi Aug 07 '23 at 16:52