You can take advantage of CSCRIPT.EXE
or WSCRIPT.EXE
(which have been present in every version of Windows since, I believe, Windows 95) like this:
echo msgbox "Hey! Here is a message!" > %tmp%\tmp.vbs
cscript /nologo %tmp%\tmp.vbs
del %tmp%\tmp.vbs
or
echo msgbox "Hey! Here is a message!" > %tmp%\tmp.vbs
wscript %tmp%\tmp.vbs
del %tmp%\tmp.vbs
You could also choose the more customizeable PopUp
command. This example gives you a 10 second window to click OK, before timing out:
echo set WshShell = WScript.CreateObject("WScript.Shell") > %tmp%\tmp.vbs
echo WScript.Quit (WshShell.Popup( "You have 10 seconds to Click 'OK'." ,10 ,"Click OK", 0)) >> %tmp%\tmp.vbs
cscript /nologo %tmp%\tmp.vbs
if %errorlevel%==1 (
echo You Clicked OK
) else (
echo The Message timed out.
)
del %tmp%\tmp.vbs
In their above context, both cscript
and wscript
will act the same. When called from a batch file, bot cscript
and wscript
will pause the batch file until they finish their script, then allow the file to continue.
When called manually from the command prompt, cscript
will not return control to the command prompt until it is finished, while wscript
will create a seprate thread for the execution of it's script, returning control to the command prompt even before it's script has finished.
Other methods discussed in this thread do not cause the execution of batch files to pause while waiting for the message to be clicked on. Your selection will be dictated by your needs.
Note: Using this method, multiple button and icon configurations are available to cover various yes/no/cancel/abort/retry queries to the user: https://technet.microsoft.com/en-us/library/ee156593.aspx