This sounds very similar to a splash screen/form that I created recently. Look 
up how to create a simple form or a powershell splash screen and call it before 
you generate your listbox, then close it after you are done.

Below is my code, in my script it is called on load and then closed at the end 
of the load event. You will need to adjust the size variables to fix your 
needs, but in your case you would do something like:

CreateLoadingWindow
<Your ListBox function here>
$formLoading.Close()


# FUNCTION: Loading screen
function CreateLoadingWindow
{
  # Form Objects
  [System.Windows.Forms.Application]::EnableVisualStyles()
  $script:formLoading = New-Object 'System.Windows.Forms.Form'
  $labelLoading = New-Object 'System.Windows.Forms.Label'
  $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
  
  # Form Events
  $Form_StateCorrection_Load =
  {
    #Correct the initial state of the form to prevent the .Net maximized form 
issue
    $formLoading.WindowState = $InitialFormWindowState
  }
  
  $Form_Cleanup_FormClosed =
  {
    #Remove all event handlers from the controls
    try
    {
      $formLoading.remove_Load($formLoading_Load)
      $formLoading.remove_Load($Form_StateCorrection_Load)
      $formLoading.remove_FormClosed($Form_Cleanup_FormClosed)
    }
    catch [Exception]
    { }
  }
  
  # Form Code
  #
  # formLoading
  #
  $formLoading.Controls.Add($labelLoading)
  $formLoading.BackColor = 'Window'
  $formLoading.ClientSize = '294, 21'
  $formLoading.ControlBox = $False
  $formLoading.Cursor = "AppStarting"
  $formLoading.FormBorderStyle = 'FixedToolWindow'
  $formLoading.Name = "NAME OF FORM"
  $formLoading.ShowIcon = $False
  $formLoading.ShowInTaskbar = $False
  $formLoading.StartPosition = 'CenterScreen'
  $formLoading.Text = "TITLE OF YOUR WINDOW"
  #
  # labelLoading
  #
  $labelLoading.Location = '2, 3'
  $labelLoading.Name = " labelLoading "
  $labelLoading.Size = '100, 16'
  $labelLoading.TabIndex = 0
  $labelLoading.Text = "PLEASE WAIT TEXT THAT IS DISPLAYED"
  $formLoading.ResumeLayout()
  
  #Save the initial state of the form
  $InitialFormWindowState = $formLoading.WindowState
  #Init the OnLoad event to correct the initial state of the form
  $formLoading.add_Load($Form_StateCorrection_Load)
  #Clean up the control events
  $formLoading.add_FormClosed($Form_Cleanup_FormClosed)
  #Show the Form
  $formLoading.Show() | Out-Null
  
}

Gavin

-----Original Message-----
From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On 
Behalf Of Michael Leone
Sent: Thursday, October 02, 2014 10:26 AM
To: powershell@lists.myitforum.com; ntsys...@lists.myitforum.com
Subject: [powershell] Powershell - how to display a msgbox with no buttons

So I have my script that pulls information from my RDS servers, and shows it as 
a listbox onscreen. Kewl!

But ... (you knew there had to be one, right?)

The script takes a while to construct that listbox (basically, I need to do 
query all the RDS servers for the list of running process for any of my 
published RemoteApps [6]), and doing all those "Get-WmiObject" calls takes a 
while). So what I want to do is display a message - "Hang on, it'll be done 
soon". But I want it to just display until the listbox is ready, then go away. 
I figure I would display that as soon as the script function to gather the 
information starts, and I want to clear it, as soon as I have enough 
information to fill the real listbox. Basically, an equivalent to the hourglass 
that is displayed when Windows is busy doing something ...

And I don't know enough .Net to know how to do that ... Oh, I can find numerous 
examples of showing a MsgBox, but they all have a "OK" button that the user is 
supposed to press, to make it go away. And that's not what I want ..

If someone could tell me exactly what sort of search terms I should be using, 
or a pointer to an example script that puts up a msgbox, and then removes the 
msgbox without user action, that would be ideal.

Thanks. Sorry to keep asking so many questions.


================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1


================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

Reply via email to