问题
I've just been messing around with CMD, and making animated ascii art. I've been attempting to use the Timeout command on my Windows 2000 laptop, however every time I attempt this, it just says it isn't an internal or external command or batch file.
This is on an old Toshiba 3110CT laptop running Windows 2000; I got it from a thrift store at some point. I've tried this on my Windows 10 laptop, and the code works perfectly fine there, but the 2000 laptop is my coding laptop, and I would like it if it were on there.
@echo off
cd %SystemRoot%\system32\
timeout.exe /t 1 /nobreak >nul
I expect for it to wait for a second, and then display the next frame of my ascii animation. Instead, it just tells me that "'timeout.exe' is not recognized as an internal or external command, operable program or batch file."
回答1:
According to this article, timeout
was only introduced on home versions of Windows starting with Vista. As such, using timeout
won't work on Windows 2000 (but will work in Windows Server 2000).
If you're still in need of making the batch wait, you can use this hacky ping call to make the batch wait for a set amount of time in milliseconds.
To make your batch wait for 1 second, do this:
ping 127.255.255.255 -n 1 -w 1000 >nul
Explanation:
127.255.255.255
is a local loopback address and is used (at least in Windows) specifically for broadcast purposes. Any requests made to this address won't get retransmitted to the client machine.-n [number]
denotes the number of times that the command should try to ping this address, in this case, 1 time.-w [number]
denotes the amount of time in milliseconds that the command should wait for a response before timing out, in this case, 1000 milliseconds.>nul
makes the output redirect from stdout to null, as such the actual output from theping
command won't show on your command prompt. If you wanted to be super safe, you could also redirect the output from stderr to null as well by adding2>nul
at the end.
来源:https://stackoverflow.com/questions/56863444/windows-2000-says-that-timeout-isnt-a-command-or-batch-file