Windows – Display message box from Task Scheduler on top of all other windows

task schedulerwindowwindows

Is there a nice way to get a message box to pop up at a scheduled time on top of other windows? The default "Display a Message" action uselessly appears below everything else.

Best Answer

How about using Window's built-in msg command like so?

msg * "Message you would like to send"

You can add other parameters such as /TIME:x where x is the number of seconds you want the message to display. Of course, msg /? will show you all the options available.

This implies Windows XP and higher as the system where you want to display the message. If you have a Home Edition of the applicable OS, you're out of luck. See for available parameters.

If you have a Home Edition, the following batch script will pop-up a message using VBSCript's PopUp method:

@echo off
::for an explanation of the PopUp method

::Use the directory from whence script was called as working directory
set CWD=%~dp0

::Use a random file name for the temporary VBScript.
set usrmsg=%CWD%%random%.vbs

::First parameter is the timeout in seconds. 0 = wait forever
set _timeout=%~1

::Second parameter is the message, enclosed in quotes.
set _Message=%~2

::Third parameter is the title of the window, enclosed in quotes.
set _Title=%~3

::This last variable is used to display a button/icon on the window.
::Setting this to 4096 sets the window to Modal (on top of everything else)
set _nType=4160

::Create the temp script using the provided information.
ECHO Set wshShell = CreateObject( "WScript.Shell" )>%usrmsg%
ECHO wshShell.Popup "%_Message%" ^& vbCrLf, %_Timeout%, "%_Title%", %_nType%>>%usrmsg%

::Run the script.
WSCRIPT.EXE %usrmsg%

::Delete the script.
DEL %usrmsg%

::Exit the batch file
exit /b

Hope this helps!

Added: Gregg mentions in the comments that in order for this to work in Windows 10, you must use "/time:0" if you want the message to stay on-screen longer than 60 seconds.