Solved

How to Get a System Tray Balloon Message Box to Appear using Microsoft Powershell

Posted on 2010-09-08
6
1,879 Views
Last Modified: 2012-05-10
How to Get a System Tray Balloon Message Box to Appear using Microsoft Powershell. I am attempting to get an application to show that it is completed or errored out during installation using a bubble message using Microsoft Powershell on several thousand PCs that need to be updated that all have Windows XP .NET 2.0 or higher on them. (Most have .NET 3.5) Could someone point me in the right direction on how to code a custom message for a bubble message in the system tray of the Windows XP OS? I apologize, but I do not have any example code for anyone to work with.
0
Comment
Question by:thenthorn1010
  • 4
6 Comments
 
LVL 2

Accepted Solution

by:
andrel39 earned 250 total points
Comment Utility
Here is a link to some example scripts that emulate vb and .net for powershell.

http://www.visualbasicscript.com/Powershell-equivalent-of-vbscript-msgbox-m83744.aspx
0
 
LVL 13

Expert Comment

by:soostibi
Comment Utility
0
 

Author Comment

by:thenthorn1010
Comment Utility
andrel39, I attempted to run the following code and I ended up with the following error message in Power Shell

"[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.MessageBox]::Show("Hello")
#System Tray Balloon Popup
     #The popup mesage
     $Message="This is a message shown in system tray balloon popup"
 
     #popup title
     $Title="Attention $env:username"
 
     # Valid Message types "Info" "Error" "Warning" "None"
     $MessageType="Info"
     
     # The number of seconds to display the message.
     [int]$duration=60
    #load Windows Forms and drawing assemblies
    [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
    [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
 
    #define an icon image pulled from PowerShell.exe
    $icon=[system.drawing.icon]::ExtractAssociatedIcon((join-path $pshome powershell.exe))
    $notify = new-object system.windows.forms.notifyicon
    $notify.icon = $icon
    $notify.visible = $True
 
    #define the tool tip icon based on the message type
    switch ($messagetype) {
     "Error" { $messageIcon=[system.windows.forms.tooltipicon]::Error}
     "Info" {$messageIcon=[system.windows.forms.tooltipicon]::Info}
     "Warning" {$messageIcon=[system.windows.forms.tooltipicon]::Warning}
     Default {$messageIcon=[system.windows.forms.tooltipicon]::None}
    }
    $notify.showballoontip($duration,$Title,$message,$MessageIcon)

  "

"The term 'Untitled1.ps1' is not recognized as the name of a cmdlet, function, script file, or opera
ble program. Check the spelling of the name, or if a path was included, verify that the path is cor
rect and try again.
At line:1 char:14
+ Untitled1.ps1 <<<<
+ CategoryInfo : ObjectNotFound: (Untitled1.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException"


Do you have any idea what would cause that error message from the example that your provided from the link you posted above?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:thenthorn1010
Comment Utility
From the two examples that are from both links, I just see a black DOS window appear and then disappear. Do you know of any other examples where the message bubble does stay on the window a bit longer than the time that it takes for the Powershell Script to stop running?
0
 

Author Comment

by:thenthorn1010
Comment Utility
After doing some more research, I did come up with the code to write a bubble, but it only makes a DOS window appear. Can anyone let me know what is wrong with this Microsoft Powershell script to make a bubble appear?

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

$objBalloon = New-Object System.Windows.Forms.NotifyIcon
# Change your Icon Here... For the Path
#$objBalloon.Icon = "C:\temp\Folder.ico"
# You can use the value Info, Warning, Error
$objBalloon.BalloonTipIcon = "Error"

# Put what you want to say here for the Start of the process
$objBalloon.BalloonTipTitle = "Sample"
$objBalloon.BalloonTipText = "Installation Successful"
$objBalloon.Visible = $True
$objBalloon.ShowBalloonTip(250000)
0
 

Author Closing Comment

by:thenthorn1010
Comment Utility
Solution required several changes to the code that had many questions within the code.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now