2

I am trying to set an icon for my wscript.shell. Not the notification icon, but the actual form icon, where the title bar is. Icon is not one of the properties, so is this even possible? It seems like it should be, but I am stumped. Can an icon be added to the popup? I am adding my code and an image showing my output. Thanks for any help

Set-StrictMode -Version latest

function monitorProcesses{
    DO{   
        foreach($name in $processList){
            if((Get-Process $name -ErrorAction SilentlyContinue) -eq $null){
            #fill our finished processes list
                if($finishedList -notcontains($name)){
                    $finishedList.Add($name) | Out-Null
                }
            }
        }
    }while($finishedList.Count -ne $processList.Count)
    $tracker.Popup("All startup processes have completed. It is safe to start the program", 10, "All Processes Complete", 0 + 4096 + 64) | Out-Null 
}


#____________________________________ Main ____________________________________#

#create initial list and empty finished list
$processList =  @('WINWORD', 'msedge')
[System.Collections.ArrayList]$finishedList = @() 
$tracker = New-Object -ComObject Wscript.Shell
$tracker.Popup("Please wait for all startup processes to end before starting the program", 10, "Please Wait", 0 + 4096 + 48) | Out-Null 
monitorProcesses 

No Icon

  • AFAIK, the WShell [Popup](https://ss64.com/vb/popup.html) method is a predefined dialog without a handle to customize the icon. Meaning that you will need to create your own dialog, see: [Assign icon to all forms in a powershell multiform gui with ps2exe](https://stackoverflow.com/a/74630305/1701026) – iRon Mar 30 '23 at 06:06

1 Answers1

2

What about using winforms for messages and have no popup Icon, but the conventional Windows message with an icon manageable with the last parameter :

# Add-Type -AssemblyName PresentationFramework  a WPF test
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
$resp = [System.Windows.Forms.MessageBox]::Show("Please wait for all startup processes to end before starting the program.","Please Wait" , "OK", "warning")

See the show method for more detail.

enter image description here

JPBlanc
  • 70,406
  • 17
  • 130
  • 175