?
Solved

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

Posted on 2010-09-08
6
Medium Priority
?
1,951 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

Question has a verified solution.

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
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

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