Skip to content

$InputObject.CloseMessageBox

Closes a MessageBox That was created as async, and is not needed any longer.

If you have called ShowMessageBox with async = $true and have reached a point in the installation where the MessageBox is no longer current, you can either show a new MessageBox with new information, which will close the already shown MessageBox, or you can simply close the initial MessageBox with CloseMessageBox()

It does not matter if the MessageBox, you are trying to close;

  • still exists, waiting for the user to click it,
  • the user has already clicked it,
  • has closed by itself, because it reached the timeout, it was created with.

:ps: void $InputObject.CloseMessageBox()

:ps: None

:ps: None

Terminal window
$cs.Job_WriteLog("Messagebox:","Showing MessageBox")
$messageBoxResponse = $InputObject.ShowMessageBox("Do not turn off", "Please do not turn off your computer. Hardware drivers are being installed", "OK", "ONE", "Info", 300, $true)
$cs.Job_WriteLog("Install:","response: $messageBoxResponse")
# for testing, wait 5 seconds
Start-Sleep -Seconds 5
$cs.Job_WriteLog("MessageBox:","Closing")
$InputObject.CloseMessageBox()
$cs.Job_WriteLog("MessageBox:","Closed")

Scripting Guidelines

Sys_BreakthruMsgbox $InputObject.ShowMessageBox