TIMEOUT no longer waits as stated

I originally posted this on Microsoft Answer Community website but got told they don't deal with this sort of question (funny, as I suspect it's a bug in one of their CMD.EXE commands or some related thing).

..... Here's my question...

Suddenly Windows 11 cmd.exe command TIMEOUT is failing for me in a CMD file - it doesn't wait the prescribed time.

e.g. TIMEOUT /T 8 reports the starting seconds for countdown and immediately exits.

In debugging things, I found that this does not occur if I manually enter it into a CMD.EXE window prompt. Further testing shows that it actually the first call of TIMEOUT in a CMD file that fails .. subsequent ones work as documented. My current circumvention is to code a TIMEOUT /T 1 at the start of the CMD file to ensure the 'real' ones behave.

A simple batch file demonstrates the effect (on my machine at least).

Batch file (saved as "test.CMD" in my case)... NB editor seems to want to combine some lines shown below .. if you use the code, just add the newlines back in.

echo on 

timeout.exe /T 8 

echo. 

echo now invoking with full path ...

%SystemRoot%\System32\timeout.exe /T 8 

echo. 

echo now invoking choice ... 

choice /T 8 /C Y /D Y /M "Press Y to continue (or wait for timeout)"

echo. 

echo do a PAUSE so you can see the results on the screen before batch file finishes running

PAUSE

Having saved this file, double-click on it run it. The first call of timeout fails, the second seems to always work. Doesn't matter if you put the full path on the timeout.exe command or not, nor in what order.

Anyone else encountered this problem? I have only been able to find the circumvention I mentioned above.

Thanks.

======================== Added as per Mofi's comment:

C:\Users\lorde>set path Path=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Users\lorde\AppData\Local\Microsoft\WindowsApps; PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

C:\Users\lorde>%SystemRoot%\System32\reg.exe query HKCU\Environment /v Path

HKEY_CURRENT_USER\Environment Path REG_EXPAND_SZ %USERPROFILE%\AppData\Local\Microsoft\WindowsApps;

C:\Users\lorde>%SystemRoot%\System32\where.exe timeout C:\Windows\System32\timeout.exe

C:\Users\lorde>%SystemRoot%\System32\reg.exe query "HKCU\Software\Microsoft\Command Processor" /v Autorun ERROR: The system was unable to find the specified registry key or value.

C:\Users\lorde>%SystemRoot%\System32\reg.exe query "HKCU\Software\Microsoft\Command Processor" /v Autorun ERROR: The system was unable to find the specified registry key or value.

C:\Users\lorde>



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation