Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: VBscript to add program to notification area?

10 May 2011   #1
TAZorich

Windows 7 64 Enterprise
 
 
VBscript to add program to notification area?

I'm creating an image which must build in an unattended fashion. The client (the end user of the resulting image) wants to have the icon for one of the included programs included in the notification area. While this CAN be done manually, because of the required build process, I do not have the option of manually adding the program to the notification area; I will need to automate this via a script or other method.

I've found VB scripts for adding ("pinning") programs to the Start Menu and Taskbar, but not for the Notification Area.

EDIT: To clarify further, I want to change the Behavior for this program from "Only show notifications" to "Show icon and notifications", but do so from a command line or script.

Can anyone point me in the right direction to getting this automated?

TIA!


My System SpecsSystem Spec
.
10 May 2011   #2
Neutron16

Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
 
 

That is a very challenging task.

Those things are kept decoded and in binary format.
HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify
"PastIconsStream" = stores the icons data
"IconStreams" = stores the program path, caption and tip

So, technically, if they are coded the same way across all computers, and you would know how your program adds and codes itself there, during installation you could dump both values from user's computer, then add your data and write new complex strings (old+yours) back in the registry.


Or you could try something like Autoit script to do it semi-manually (but user will see what is going on).

Or you could force them all to Show icon and notification (Option two here), but that would not be fair to the end user.


I do not see an easy elegant solution here.
My System SpecsSystem Spec
07 Sep 2012   #3
StolliV

Windows7
 
 

I have solved this issue finally. I spent 6 hours looking for this answer today .... i'll post the full solution tomorrow as its time to head home now.
My System SpecsSystem Spec
.

10 Sep 2012   #4
StolliV

Windows7
 
 

So here's my solution ....

2 files are required for this. A .bat file and a .ps1 file.

Take the powershell code from this website, which i DID NOT write, so i wont take credit for (read the whole page, it explains it in full detail) and paste that code in the .ps1 file. Thats all you need to do with this file.

Windows 7 Notification Area Automation – Falling Back Down the Binary Registry Rabbit Hole Xtreme Deployment

The second file is a .bat file, where you'll put the commands to run the .ps1 file. The powershell script takes 2 inputs, the first is the name of the notification icon you want to make the change to, and the second is which of the three available options you want to set.

  • 0 = only show notifications
  • 1 = hide icon and notifications
  • 2 = show icon and notifications

For my specific application of this solution, I wanted to set the Zenworks Notification Icon to level 2 so its always in the notification area for users to click on since there is a lot of easy to access information available from there. IP address, system name ... things they need to get support from our helpdesk.

so my .bat file looks like this:

taskkill /im explorer.exe /f
powershell Set-ExecutionPolicy Unrestricted
powershell .\ZNIexeEdit.ps1 ZenNotifyIcon.exe 2
powershell Set-ExecutionPolicy Restricted
explorer.exe

you kill windows explorer, which is necessary for the script to change the registry entry that controls the notification icons

HKCU\Software\Classes\Local Settings\Microsoft\Windows\CurrentVersion\TrayNotify\IconStreams

then you have to set the rights level of powershell

then you call your script with your 2 parameters

then you set the rights level of powershell back to its original state cuz you dont wanna leave it unrestricted

then you restart explorer

all done. both the .bat and the .ps1 need to be in the same directory, i used them right out of C:\ and you just need to launch the .bat file. so you have 2 small files that are easy to distribute through whatever means.

it is important that the actual user of the machine be logged in at the time the .bat file is executed.
My System SpecsSystem Spec
19 Jul 2014   #5
ericdu35

Windows 7 Pro SP1 x64
 
 
Information

I applied the script "NotifyIcon.ps1" and "NotifyIcon.bat" by GPO but the policy does not apply to the Windows Update icon in systray.

How did you do?

NotifyIcon.bat
taskkill /im explorer.exe /f
powershell Set-ExecutionPolicy Unrestricted
powershell .\NotifyIcon.ps1 wuauclt.exe 2
powershell Set-ExecutionPolicy Restricted
explorer.exe

NotifyIcon.ps1
param(
[Parameter(Mandatory=$true,HelpMessage='The name of the program')][string]$ProgramName,
[Parameter(Mandatory=$true,HelpMessage='The setting (2 = show icon and notifications 1 = hide icon and notifications, 0 = only show notifications')]
[ValidateScript({if ($_ -lt 0 -or $_ -gt 2) { throw 'Invalid setting' } return $true})]
[Int16]$Setting
)

$encText = New-Object System.Text.UTF8Encoding
[byte[]] $bytRegKey = @()
$strRegKey = ""
$bytRegKey = $(Get-ItemProperty $(Get-Item 'HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify').PSPath).IconStreams
for($x=0; $x -le $bytRegKey.Count; $x++)
{
$tempString = [Convert]::ToString($bytRegKey[$x], 16)
switch($tempString.Length)
{
0 {$strRegKey += "00"}
1 {$strRegKey += "0" + $tempString}
2 {$strRegKey += $tempString}
}
}
[byte[]] $bytTempAppPath = @()
$bytTempAppPath = $encText.GetBytes($ProgramName)
[byte[]] $bytAppPath = @()
$strAppPath = ""

Function Rot13($byteToRot)
{
if($byteToRot -gt 64 -and $byteToRot -lt 91)
{
$bytRot = $($($byteToRot - 64 + 13) % 26 + 64)
return $bytRot
}
elseif($byteToRot -gt 96 -and $byteToRot -lt 123)
{
$bytRot = $($($byteToRot - 96 + 13) % 26 + 96)
return $bytRot
}
else
{
return $byteToRot
}
}

for($x = 0; $x -lt $bytTempAppPath.Count * 2; $x++)
{
If($x % 2 -eq 0)
{
$curbyte = $bytTempAppPath[$([Int]($x / 2))]
$bytAppPath += Rot13($curbyte)

}
Else
{
$bytAppPath += 0
}
}

for($x=0; $x -lt $bytAppPath.Count; $x++)
{
$tempString = [Convert]::ToString($bytAppPath[$x], 16)
switch($tempString.Length)
{
0 {$strAppPath += "00"}
1 {$strAppPath += "0" + $tempString}
2 {$strAppPath += $tempString}
}
}
if(-not $strRegKey.Contains($strAppPath))
{
Write-Host Program not found. Programs are case sensitive.
break
}

[byte[]] $header = @()
$items = @{}
for($x=0; $x -lt 20; $x++)
{
$header += $bytRegKey[$x]
}

for($x=0; $x -lt $(($bytRegKey.Count-20)/1640); $x++)
{
[byte[]] $item=@()
$startingByte = 20 + ($x*1640)
$item += $bytRegKey[$($startingByte)..$($startingByte+1639)]
$items.Add($startingByte.ToString(), $item)
}

foreach($key in $items.Keys)
{
$item = $items[$key]
$strItem = ""
$tempString = ""

for($x=0; $x -le $item.Count; $x++)
{
$tempString = [Convert]::ToString($item[$x], 16)
switch($tempString.Length)
{
0 {$strItem += "00"}
1 {$strItem += "0" + $tempString}
2 {$strItem += $tempString}
}
}
if($strItem.Contains($strAppPath))
{
Write-Host Item Found with $ProgramName in item starting with byte $key
$bytRegKey[$([Convert]::ToInt32($key)+528)] = $setting
Set-ItemProperty $($(Get-Item 'HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify').PSPath) -name IconStreams -value $bytRegKey
}
}
My System SpecsSystem Spec
Reply

 VBscript to add program to notification area?




Thread Tools




Similar help and support threads
Thread Forum
How to add a program to notification area of taskbar
Can I add a program to those available for the notification area of the task-bar? How? Can I delete a program from those available for the notification area of the task-bar? How? There are programs that I do not use in the notification area and I want others.
General Discussion
Notification area customization reset when program not running
I have customized the Notification Area so that some items are hidden and some are not. However, when a program that I've set to "Show icon and notification" stops running for any reason, its customization reverts back to "Only show notifications", even after the program has been restarted. So I...
General Discussion
How to Add Program Icons to the Notification Area?
Many programs add their own icons to the Notification Area, Others never do it, but sometimes it is convenient. I have been searching for a long time for how to add an icon to a couple of programs, and couldn't find a tutorial here. Almost all have icons included with their executive files, so...
Customization
Notification Area
I've searched this and other sites for an answer to the question "how do I increase the size of the notification area icons"? (Earlier called the system tray). All threads seem to lead to adjustments to the quick launch bar. I can use the advanced appearance windows but this also affects the...
Customization
Notification area
I've read Brink's excellent tutorial on how to change this area's settings. I changed the length of time a message appears. I'd like to test what I've done. How do I create a benign notification or action center message to test how long it remains on the screen? Thanks.
Performance & Maintenance
Uninstalled Program Remains on Notification Area List
I uninstalled Lavasoft Ad-Aware application and noticed that the its program tray icon is still showing on the Notification Area List. Is there a way to remove it?
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 07:29.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App