windows - “超时 - t”与“超时”。有什么实际区别吗?
问题描述
我一直在挑战自己用尽可能少的字符重写我的一个批处理项目,并开始怀疑 -t 是否有任何目的。
显然,以下两个脚本在执行时的行为方式完全相同。
timeout -t 5
echo test
pause
timeout 5
echo test
pause
微软文档(https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/timeout_1)和 ss64 (https://ss64.com/nt/timeout.html)都没有提及有关 -t 是否必要的任何内容。
解决方案
该timeout
命令自己的/?
帮助显示[/T]
在括号中,表明它是可选的。
C:\>timeout /?
TIMEOUT [/T] timeout [/NOBREAK]
Description:
This utility accepts a timeout parameter to wait for the specified
time period (in seconds) or until any key is pressed. It also
accepts a parameter to ignore the key press.
...
给定无效参数时显示的错误消息也提到/T
,无论它是否在命令行上实际指定。
C:\>timeout ***
ERROR: Invalid value for timeout (/T) specified. Valid range is -1 to 99999.
可选的/T
开关可能是为了向后兼容,因为timeout
与 NT4/2000 资源工具包一起发布的早期版本没有/T
开关。例如,这是timeout.exe
来自Windows 2000 Server Resource Kit Supplement 1的。
C:\>dir C:\etc\*.exe | find /i "timeout"
12/02/1999 03:54 PM 62,464 TIMEOUT.EXE
C:\>C:\etc\timeout /?
TIMEOUT - This utility is similar to the DOS PAUSE command. However, it
accepts a timeout parameter to specify a length of wait (in seconds)
at which time it will continue without a key press.
Written by Eric Brown, Business System Division.
Copyright (C) Microsoft Corporation, 1992-1995.
Usage - TIMEOUT <###>
where <###> is a decimal number of seconds between -1 and 100000.
The value -1 means to wait indefinitely for a key hit.
推荐阅读
- python - 阻止 Tensorflow 根据请求重新加载模型
- windows - 什么是压缩 GUID,为什么要使用它?
- javascript - 实现格路径计数的递归
- javascript - 如何在javascript中的变量中定义变量
- javascript - 如何向 Angular 应用程序发出 CORS HTTP 请求
- android - 代理设置不适用于 Chrome Webview
- c# - ASP.NET 设置用户身份和 IsAuthenticated = true
- azure-ad-b2c - 更新 Azure B2C 自定义策略中的显示名称
- sinch - Android Sinch PubNubListener:6 次尝试后永久订阅失败
- c# - PlaceHolder 重复按钮单击插入错误太多参数