Show a popup/message box from a Windows batch file

billyy picture billyy · Apr 21, 2009 · Viewed 583.8k times · Source

Is there a way to display a message box from a batch file (similar to how xmessage can be used from bash-scripts in Linux)?

Answer

Joey picture Joey · Apr 21, 2009

First of all, DOS has nothing to do with it, you probably want a Windows command line solution (again: no DOS, pure Windows, just not a Window, but a Console).

You can either use the VBScript method provided by boflynn or you can mis-use net send or msg. net send works only on older versions of windows:

net send localhost Some message to display

This also depends on the Messenger service to run, though.

For newer versions (XP and onward, apparently):

msg "%username%" Some message to display

It should be noted that a message box sent using msg.exe will only last for 60 seconds. This can however be overridden with the /time:xx switch.