Solved

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

Posted on 2010-09-08
6
1,918 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 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
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 …

738 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