Did you find this useful?
Socialize it today.

Create a Pop-up Message using VBScript

Friday, October 28, 2011

The "Popup" method produces a pop-up message box which can display a message to a user for a specified amount of time. If the message time is omitted or set to zero, the pop-up will remain until the user dismisses the message. In addition, a title can be assigned to the pop-up message.  If it is omitted, the default is "Windows Script Host".
The syntax is as follows:

WshShell.Popup strText[,nSecondsToWait] [,strTitle] [,nType]


String value containing the text you want to appear in the pop-up message box.

Optional. Numeric value indicating the maximum length of time (in seconds) you want the pop-up message box displayed.

Optional. String value containing the text you want to appear as the title of the pop-up message box.

Optional. Numeric value indicating the type of buttons and icons you want in the pop-up message box. These determine how the message box is used.

Integer value indicating the number of the button the user clicked to dismiss the message box. This is the value returned by the Popup method.

Button Types
0-Show OK button.
1-Show OK and Cancel buttons.
2-Show Abort, Retry, and Ignore buttons.
3-Show Yes, No, and Cancel buttons.
4-Show Yes and No buttons.
5-Show Retry and Cancel buttons.

16-Show "Stop Mark" icon.
32-Show "Question Mark" icon.
48-Show "Exclamation Mark" icon.
64-Show "Information Mark" icon.

intButton Return Codes
1-OK button
2-Cancel button
3-Abort button
4-Retry button
5-Ignore button
6-Yes button
7-No button

If the user does not click a button before nSecondsToWait seconds, intButton is set to -1.


Dim WshShell, BtnCode
Set WshShell = WScript.CreateObject("WScript.Shell")
BtnCode = WshShell.Popup("Do you like your job?", 7, "Answer This Question:", 4 + 32)
Select Case BtnCode
case 6 WScript.Echo "That's great!."
case 7 WScript.Echo "Sorry to hear that."
case -1 WScript.Echo "No Response?"
End Select

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.

Recommended Books & Training Resources

Advanced VBScript for Microsoft Windows Administrators Microsoft WSH and VBScript Programming for the Absolute Beginner