Results 1 to 5 of 5

Thread: How to add application to notification area via VBscript?

  1. #1
    Join Date
    Sep 2012
    Posts
    23

    How to add application to notification area via VBscript?

    I am developing a software to maintain the database of a fitness centre and I have almost completed it. Since there are many centers all over our town, the software would be distributed among various centers. The software will have feature to send internal messages. Now to show the user that message has been received, there will be a notification that will be popping up in the quick launch bar. I am having difficulty making the notification pop-up in the quick launch bar in Windows 7. Can someone tell me how to get the active notification in the software when it is minimized and is in the quick launch bar?

  2. #2
    Join Date
    May 2009
    Posts
    527

    Re: How to add application to notification area via VBscript?

    The primary reason of software getting notification on the quick launch bar is because of the following registry key,
    HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify.
    The problem is that all the data that is stored in this registry key is in the binary form. In this Registry Key, in the ending part of TrayNotify, if you put ‘PastIconsStream’, you will find the information where the icons and logos are stored. Another registry key is ‘IconStreams’, it stores the program path, caption and tip for the designated software. You will need to have good knowledge of binary code to use this registry key.

  3. #3
    Join Date
    Feb 2012
    Posts
    98

    Re: How to add application to notification area via VBscript?

    The method that 'Shreevats' has told in his post is good, but I don’t think that it is practical. Since you are making this software for your client, it is obvious that the client will be using different computer. The registry key of his computer might be different than yours. Also the built of his hardware and operating system might be very different than yours. So if you edit the registry key for the notification of the software in your computer, there are less chances of the same registry key being presented in your client’s computer. If you are going to edit the registry key, then you will need to use some method which will match the registry key of your client’s computer with registry key of your computer.

  4. #4
    Join Date
    Feb 2012
    Posts
    94

    Re: How to add application to notification area via VBscript?

    I have found a way to generate the notification for the software that is developed using Visual Basic. I used two different files to achieve it, one is a .bat file and other one is the.ps1 file. In the .ps1 file, I inserted following code which I have posted below:

    Code:
    param(
        [Parameter(Mandatory=$true,HelpMessage='insert name of program here')][string]$NameofProgram,
        [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($NameofProgram)
    [byte[]] $bytAppPath = @()
    $strAppPath = ""
    
    Function Rot13($byteRot)
    {
        if($byteRot -gt 64 -and $byteRot -lt 91)
        {
            $bytRot01 = $($($byteRot - 64 + 13) % 26 + 64)
            return $bytRot01
        }
        elseif($byteRot -gt 96 -and $byteRot -lt 123)
        {
            $bytRot01 = $($($byteRot - 96 + 13) % 26 + 96)
            return $bytRot01
        }
        else
        {
            return $byteRot
        }
    }
    
    for($x = 0; $x -lt $bytTempAppPath.Count * 2; $x++)
    {
        If($x % 2 -eq 0)
        {
            $curbyte01 = $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 $NameofProgram 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
        }
    }
    [Note that I have made this code according to my need, you can edit according to your need and computer’s built.]

    Now you will have to make a .bat file which will run the .ps1 file that you have just made. Now the software will have various forms, that is when notification will be shown, when not and so on. I have designed three types of conditions for it. Here they are:

    0 = should only show the notifications
    1 = no notification and icon must be shown
    2 = icon as well as notification must be shown
    You can now set the icon for the software and notification in the quick launch area. You will have to deal with the IP address and system name by yourself. To play with the bat file and the ps1 file to generate the notification, you will also have to involve the explorer.exe to get things done. Now that we know what we have to do, here is how you will make the .bat file. This is how the .bat file I made looks like:

    Code:
    taskkill /im explorer.exe /f
    powershell Set-ExecutionPolicy Unrestricted
    powershell .\ZNIexeEdit.ps1 ZenNotifyIcon.exe 2
    powershell Set-ExecutionPolicy Restricted
    explorer.exe
    This will launch the code for .ps1 file that I have given and you can then pass any two parameter that I have suggested. This is the only way that I have found which is possible to achieve the notification. You will need to place the .bat file and the ps1 file in the same folder to make them work properly.

  5. #5
    Join Date
    Sep 2012
    Posts
    23

    Re: How to add application to notification area via VBscript?

    I tried the above method and I think that it is a good way. The only problem I found is that every time a notification has to be generated, the .bat is launched. The.bat file actually kills the explorer.exe ad then again starts it. Though the whole method is safe, it is not good from old computers or computers with slow working. In such machines, if multiple notifications arrive at a time, it will get overloaded with request to kill explorer.exe and re-incarnate it again. This will certainly crash he computer.

Similar Threads

  1. No Animation in Lan notification area icon
    By Uyonga in forum Operating Systems
    Replies: 3
    Last Post: 04-12-2010, 06:25 AM
  2. Notification area configuration in windows 7
    By Chandranath in forum Windows Software
    Replies: 5
    Last Post: 31-01-2010, 04:44 AM
  3. Hide some icons in the notification area
    By MAGAR in forum Customize Desktop
    Replies: 4
    Last Post: 25-11-2009, 08:00 PM
  4. To customize notification area
    By Dyumani in forum Customize Desktop
    Replies: 3
    Last Post: 24-04-2009, 11:10 AM
  5. Network Notification area Greyed out
    By Sadashiva in forum Networking & Security
    Replies: 3
    Last Post: 19-02-2009, 08:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •