How can I display a dialog box on Win-7 or win-10 for 5 seconds, from the command line?
Solution 1:
Assuming that:
- You aren't interested in knowing if the window timed out
- You aren't interested in knowing what button the user clicked on
- You don't mind writing out a temporary VBScript file to generate the popup (and then removing it after)
then use the following:
echo WScript.CreateObject("Wscript.Shell").Popup "Line 1" ^& vbCrLf ^& "Line 2", 10, "Title", 262192 > %temp%\File.vbs
wscript %temp%\File.vbs
del /f %temp%\File.vbs
This will cause a pop-up to appear which has two lines of content ("Line 1" followed by "Line 2"), the title "Title", an exclamation icon, an OK button and a timeout of 10 seconds.
Further details on how to configure this window can be found in the documentation for the Popup command.
It’s worth noting that you can achieve an exclamation mark and an “OK” button with 48
instead of 262192
(which, technically, isn’t a valid numerical option).