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
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:
This is simply a variable that contains the message we want to display.
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.