Diese Messagebox könnte man einsetzen, nachdem eine Softwareinstallation abgeschlossen wurde. 

Der Aufruf könnte so erfolgen:

View source
  1. "%windir%\system32\cmd.exe" /c Start "" "%windir%\system32\windowspowershell\v1.0\powershell.exe" -NoProfile -Noexit -Windowstyle hidden -ExecutionPolicy RemoteSigned -File "%SOURCEDIR%\tools\Adobe_Acrobat_MSGBox.ps1"

View source
  1. #MessageBox Sample
  2. ###############################
  3.  
  4. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
  5. [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
  6.  
  7. $dForm = New-Object System.Windows.Forms.Form
  8. $dForm.Size = new-object System.Drawing.Size 640,200
  9. $dForm.Text = "Adobe Acrobat Professional"
  10. $dText = New-Object System.Windows.Forms.TextBox
  11. $dText.ScrollBars = "none"
  12. $dText.Dock = "fill"
  13. $dText.Multiline = $true
  14. $dText.Parent = $dForm
  15. $dText.ReadOnly = $true
  16.  
  17. #Add-TextToWindow "The date is $(get-date)`n"
  18. Add-TextToWindow "Um die Installation des Programms abzuschliessen ist ein Neustart erforderlich. Dieser wird nicht automatisch durchgeführt!`n"
  19. Add-TextToWindow "`n"
  20. Add-TextToWindow "`n"
  21. Add-TextToWindow "The system needs to be restarted to finish the installation. The restart will not be done automatically!"
  22.  
  23. $dForm.Add_Shown({$dform.Activate()})
  24. #
  25. # Create the new runspace
  26. #
  27. $rs = [Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()
  28. $rs.Open()
  29.  
  30. # pass in the form object...
  31.  
  32. $rs.SessionStateProxy.SetVariable("dForm", $dForm)
  33.  
  34. # and set up a synchronized data interchange object
  35. # between the two runspaces...
  36.  
  37. $data = [hashtable]::Synchronized(@{text=""})
  38. $rs.SessionStateProxy.SetVariable("data", $data)
  39.  
  40. # Start the pipeline so the form will display...
  41.  
  42. $p = $rs.CreatePipeline({ [void] $dForm.ShowDialog()})
  43. $p.Input.Close()
  44. $p.InvokeAsync()
  45. function Add-TextToWindow($text)
  46. {
  47. [eventhandler] $eh = {
  48. $this.AppendText($data.text)
  49. }
  50. $data.text = $text
  51. do {
  52. $retry = @($false)
  53. trap [InvalidOperationException] {
  54. start-sleep -milli 100
  55. $retry[0] = $true
  56. continue
  57. }
  58. $dText.Invoke($eh, ($dText, [eventargs]::empty))
  59. } while ($retry[0])
  60. }