Solved

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

Posted on 2010-09-08
6
1,887 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
ID: 33627775
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
ID: 33628354
0
 

Author Comment

by:thenthorn1010
ID: 33628520
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:thenthorn1010
ID: 33629289
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
ID: 33629879
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
ID: 33630577
Solution required several changes to the code that had many questions within the code.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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 …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

911 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

18 Experts available now in Live!

Get 1:1 Help Now