Did I miss a change of the Windows internal "timeout" command?
I have a batch file for a long time now that shows me the version number of a program. I added the timeout command to keep the CMD window opened for a few seconds. So my batch file now looks like this:
context -version
timeout 7
This worked fine but since some Windows update (obviously), the CMD windows closes directly as if the timeout command doesn't work anymore. When I start the file from a CMD window I get a message:
D:\CTX>timeout 7
Try 'timeout --help' for more information.
The file is as it was since I created it, but the behavior is new to me.
So can anybody tell me what I is going wrong here?
TIMEOUT is not an internal command of
cmd.exe
(Windows command interpreter) like FOR or DIR.It is an external command which means a console application being located in the Windows directory
%SystemRoot%\System32
.On using just
timeout
without file extension and without full path, Windows command interpreter searches first in current directory withtimeout.*
for a file having a file extension listed in environment variable PATHEXT.If no such file can be found in current directory, Windows command interpreter continues the search for
timeout.*
with a file extension listed in PATHEXT in the directories defined in environment variable PATH.On Windows Vista and later versions of Windows the system PATH is defined with:
For that reason it is usually found first
%SystemRoot%\System32\timeout.exe
on using justtimeout
in a batch file.But if the current directory contains a file with name
timeout.*
having a file extension listed also in environment variable PATHEXT, or PATH was redefined locally or system wide by an installer which put other directory paths at beginning instead of appending them at end and one of these directories contain also atimeout.*
file, Windows command interpreter runs this executable or script.The suggestions for solving this problem:
Use in the batch file
%SystemRoot%\System32\timeout.exe
because then Windows command interpreter must not search for this executable and it can't happen that the wrongtimeout
is executed mistakenly, except environment variableSystemRoot
is modified locally which is very unlikely in comparison toPATH
manipulations.Open Windows Control Panel - System - Advanced system settings (blue link on left side), select tab Advanced, click on button Environment Variables..., search in lower half in list of System variables for Path, select this environment variable, click on Edit, and move all directory paths left or above (depends on Windows version) of
%SystemRoot%\system32
to end of the directories list.Please report to the author of the application or software bundle which modified system PATH and inserted their directory paths at beginning instead of appending them at end about this wrong modification of Windows system PATH.
As Magoo wrote already: a
timeout.*
ported from Unix to Windows is obviously executed on your Windows machine because of the output help statement. To get help on a command on Windows the command has to be executed usually with parameter/?
and not with-h
or--help
as on Unix.I believe you've probably acquired a different version of
timeout
since the help prompt--help
is a\*nixy
style option-specifier.Try, from the prompt
which should list the
timeout
versions on thepath
and may assist in locating the rogue version.