How to Display a Msgbox directly from CMD

How to Display a Msgbox directly from CMD

I needed something similar to this today. Since I couldn’t find an external dependency solution I liked since I’m not really a fan of VBScript/Powershell, I went ahead and wrote one:

The message boxes it produces are modal to the current console window. That is, the user can’t do anything until they close the dialog. Also, the return code from the MessageBox() call is returned to the caller so that a script can react to whichever button was pressed. And, of course, it supports the full range of options to the MessageBox() Win32 API.

Adding an 80KB executable to the mix might not be everyone’s cup of tea. It is statically linked against the VC++ runtime though and supports Unicode, which explains why the file is so large given the minimalistic nature of what it does. And there is a minor issue of not being able to easily pass in newlines from the command-line to display multiline messages. On a minor upside, it displays the dialog in less wall clock time than any of the other solutions presented so far.

Of course, if file size doesn’t matter and dialogs create a too “in your face” user experience and/or don’t require user interaction, I also ran into this nifty project:

Which displays a popup balloon in the status notification area of the screen using IUserNotification. The downside is that the Notifu executable runs just shy of 240KB. Another unfortunate example that COM creates unnecessary bloat and leaves me wishing that there was a simple, lightweight API for the feature.

For something cross-platform, there’s zenity. It’s mostly for Linux but there are Mac and Windows ports too. The Windows port of zenity is over 1MB in size because, well, GTK is quite bloated.


Leave a Reply