Message Box Script for Lite Touch Task Sequences

I recently had the need to pop up a message box duing an LTI task sequence.  I was creating a stand-alone wizard to allow a manually-initiated launch of a task sequence that would install the Service Pack 1 update on Windows Server 2008 R2.  As part of this task sequence, if a certain software package was of a certain version or earlier we had to reinstall this software after the service pack installation.  If this installation was not going to happen because a newer version was already installed, the customer wanted to notify the technician at the end of the process.  Since this was to be a simple notification, a message box was sufficient.  I could have simply created a VBScript that had a static MsgBox function call for this purpose.

However, I decided that I would make it more reusable than that.  Instead I created an MDT script that would take the input arguments for the the MsgBox function as command line parameters.  That way the script could be reused any time a message box was needed.  The script can also optionally use the MsgBox return value as the script exit code and/or use it as the value for a task sequence variable.

The usage for this script is as follows (optional switches in brackets):

cscript.exe MDTMessageBox.wsf /text:"<message text>"
[/type:<button/icon type>]
            [/title:"<title of the pop-up message box>"]
[/seconds:<seconds the pop-up message box is displayed>]
[/returnexit] (If specified, button click return value will be used as script exit code.)
[/returnvar:<task sequence variable to set with the button click return value]

The /type switch value uses the MsgBox buttons argument value as documented here.  If the /seconds switch is not used, the message box will remain until a button is clicked.

If you call the script directly like this:

cscript.exe "%SCRIPTROOT%\MDTMessageBox.wsf" /text:"Hello World" /type:64 /title:"Greetings"

the task sequence will not continue until a message box button is clicked.  This is a useful way to briefly pause the task sequence for a quick examination or tweak.

If you want to pop up a message box but have the task sequence continue, use a command line like the following:

cmd /c start "" wscript.exe "%SCRIPTROOT%\MDTMessageBox.wsf" /text:"Hello World" /type:64 /title:"Greetings"


Disclaimer: The information on this site is provided "AS IS" with no warranties, confers no rights, and is not supported by the authors or Microsoft Corporation. Use of included script samples are subject to the terms specified in the Terms of Use .

This post was contributed by Michael Murgolo, a Senior Consultant with Microsoft Services - U.S. East Region.