[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2010-09-08
6
Medium Priority
?
1,971 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 2

Accepted Solution

by:
andrel39 earned 750 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
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 

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

Q2 2017 - Latest Malware & Internet Attacks

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out our latest Quarterly Internet Security Report!

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Introduction to Processes

649 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