Skip to content

$InputObject.ShowMessageBox

Shows a MessageBox to the logged on user. If a MessageBox is already shown, it will be replaced.

The MessageBox is displayed by CapaInstaller InfoCenter as a notification in the lower-right corner of the user’s screen. $InputObject only exists when the agent runs the PowerPack, so you can’t use this function when you run the script by hand.

If InfoCenter isn’t running in a user session, the agent waits up to 5 minutes for it to start. If InfoCenter still isn’t available, for example because no user is logged on, nothing is shown and the function returns the default button.

[string] $InputObject.ShowMessageBox(title, message, buttons, defaultButton, icon, timeoutSeconds, async)

There are no specific considerations for the use of special characters (unlike Sys_BreakThruMsgBox)

Title of the messagebox. Titles longer than 75 characters are shortened.

Text in the messagebox

Specifies button-type. Valid values: ‘OK’, ‘YESNO’, ‘YESNOCANCEL’, ‘ABORTRETRYIGNORE’, ‘OKCANCEL’ and ‘RETRYCANCEL’

Specifies the default button in messagebox. Valid values: ‘ONE’, ‘TWO’ or ‘THREE’. ‘ONE’ is the first button named in buttons — for example, Yes in ‘YESNOCANCEL’.

Icon-style of the messagebox. Valid values: ‘STOP’, ‘QUESTION’, ‘EXCLAMATION’, ‘INFORMATION’. InfoCenter currently shows the same icon for every style.

Number of seconds the messagebox is shown. If the user has not clicked any of the buttons within the timeout, the messagebox closes and the default button is returned

Specifies if the messagebox displays asynchronously($true) or waits for the user to respond($false)

Result will be returned from the function. Valid answers are: ‘OK’, ‘YES’, ‘NO’, ‘ABORT’, ‘RETRY’, ‘CANCEL’ and ‘IGNORE’

When async is $true, the function returns right away with an empty string. To remove an asynchronous MessageBox before it times out, call $InputObject.CloseMessageBox.

Terminal window
$cs.Job_WriteLog("Showing MessageBox")
$messageBoxResponse = $InputObject.ShowMessageBox("MessageBox title", "This is a test messageBox from a PowerPack (æøå). Please click one of the three buttons below", "YESNOCANCEL", "TWO", "QUESTION", 180, $false)
$cs.Job_WriteLog("response: $messageBoxResponse")

Scripting Guidelines

Sys_BreakthruMsgbox $InputObject.CloseMessageBox