Windows [cmd.exe] 命令显示超时消息框? [英] Windows [cmd.exe] command to display a messagebox with timeout?
问题描述
注意:这是一个question-with-answer,以便记录其他人可能认为有用的技术,以便了解其他人"更好的解决方案.请随意添加批评或问题作为评论.也请随意添加其他答案.:)
如何通过键入单个 Windows 命令来显示 消息框,例如在开始"菜单的运行对话框中,还是在 [cmd.exe] 命令解释器中?
How can I display a messagebox by typing a single Windows command, e.g. in the Run dialog from the Start menu, or in the [cmd.exe] command interpreter?
推荐答案
一种方法是使用明显未记录的功能,即 [mshta.exe],Windows .hta HTML 应用程序的运行时引擎,接受通用 URL 作为命令行参数,包括 javascript:
协议 URL:
One way is to use apparently undocumented functionality, namely that [mshta.exe], the runtime engine for Windows .hta HTML applications, accepts a general URL as command line argument, including a javascript:
protocol URL:
mshta "javascript:var sh=new ActiveXObject( 'WScript.Shell' ); sh.Popup( 'Message!', 10, 'Title!', 64 );close()"
此命令可以在例如[cmd.exe]],或例如在开始"菜单的 Run 对话框中,也许可以结合 schtasks
命令来创建一个茶歇…
This command can be issued in e.g. [cmd.exe]], or e.g. in the Run dialog from the Start menu, perhaps combined with the schtasks
command to create a tea-timer…
上述消息框在 10 秒后超时,但指定 0 秒超时意味着不要超时",产生更普通的持久消息框.
The above messagebox times out after 10 seconds, but specifying a 0 second timeout means “don’t time out”, producing a more ordinary persistent messagebox.
对于更简单的消息框,您可以改用 MSHTA 主机提供的 alert
功能.
For a simpler messagebox you can instead use the alert
function provided by the MSHTA host.
这篇关于Windows [cmd.exe] 命令显示超时消息框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!