IProgressUI::ShowMessageEx method

Starting in version 2006, the ShowMessageEx method displays a customizable dialog box. This method is similar to the IProgressUI::ShowMessage method, but also includes a new integer result variable, pResult.


HRESULT ShowMessageEx(  
     BSTR pszText,  
     BSTR pszCaption,  
     ULONG uType,
     INT *pResult



Data type: BSTR

Qualifiers: [in]

The text displayed in the message box body.


Data type: BSTR

Qualifiers: [in]

The text displayed in the message box windows header.


Data type: ULONG

Qualifiers: [in]

The value corresponding to one of the following possible values for the buttons:

  • 0 - Ok
  • 1 - Ok/Cancel
  • 2 - Abort/Retry/Ignore
  • 3 - Yes/No/Cancel
  • 4 - Yes/No
  • 5 - Retry/Cancel
  • 6 - Cancel/Try Again/Continue


Data type: INT

Qualifiers: [out]

The value of this variable is a standard Windows message box return value.

Return values

An HRESULT code. Possible values include, but aren't limited to, the following value. There are no HRESULT values returned that are specific to this method.

The method succeeded.

To evaluate the user's response to the message box, use the pResult parameter.


The following PowerShell script sample shows how to use this method:

$Message = "Can you see this message?"
$Title = "Contoso IT"
$Type = 4 # Yes/No
$Output = 0

$TaskSequenceProgressUi = New-Object -ComObject "Microsoft.SMS.TSProgressUI"
$TaskSequenceProgressUi.ShowMessageEx($Message, $Title, $Type, [ref]$Output)

$TSEnv = New-Object -ComObject "Microsoft.SMS.TSEnvironment"
if ($Output -eq 6) {
$TSEnv.Value("TS-UserPressedButton") = 'Yes'

You can use a script like this in the Run PowerShell Script step in the task sequence. If the user selects Yes in the custom window, the script creates a custom task sequence variable TS-UserPressedButton with a value of Yes. You can then use this task sequence variable in other scripts or as a condition on other task sequence steps.

See also