How Do I Change the Title of a Message Box?

How Do I Change the Title of a Message Box?

  • Comments 1
  • Likes
Hey, Scripting Guy! Question

Hey, Scripting Guy! Whenever I use a message box, the caption reads Windows Script Host. Is there any way to change that caption?

-- TT, Reno, NV

SpacerHey, Scripting Guy! AnswerScript Center

Hey, TT. To answer your question, no, not if you’re using Wscript.Echo; in that case, you’re stuck with the caption Windows Script Host. However, you can create a custom caption using the VBScript Msgbox function. For example:

strMessage = "Here is my message."
Msgbox strMessage, 0, "This is my message box"

In this sample script, we’re passing three parameters to the Msgbox function:

strMessage

This is simply a variable that contains the message we want to display.

0

This value indicates that the message box should only have an OK button. By passing different values, you can display message boxes that have Yes and No buttons, message boxes that have Abort, Retry, Ignore buttons, etc.

“This is my message box.”

This is the custom caption you want displayed on your message box.

There’s one important thing to keep in mind here. When you use Wscript.Echo, your messages are displayed in a message box only if you are running under Wscript; if you are running under CScript messages are echoed to the command windows instead. With the Msgbox function, messages are always displayed in message boxes, regardless of which script host you are using.

For more information about modifying message box parameters, see the VBScript documentation on MSDN.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Also, wshshell.popup does a fine job.