You are here

Can NSIS stop/start an aplication? // Past Systray icons

12 posts / 0 new
Last post
BrianAll
Offline
Last seen: 4 years 7 months ago
Joined: 2008-02-13 13:44
Can NSIS stop/start an aplication? // Past Systray icons

Okay, I found this out a while ago.
When a portable application such as Pidgin or Miranda runs, windows will store the settings for the behavior of the system tray icon [Always Show, Always Hide, Hide when Inactive] in the registry. However, when the program closes, these settings are kept and will be displayed under "Past Items" in the customize notifications part of the Taskbar & Start Menu Properties. This exposes all the applications which use system tray icons, that have previously been running on the computer. Shock *gasps*

Fortunately, Microsoft has a solution for this issue: Blum

To clear the Past Items list, perform the following steps:

  1. Delete the IconStreams and PastIconsStream values from the following registry key using regedit.exe:
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify
  2. Open Task Manager, click the Processes tab, click Explorer.exe, and then click End Process.
  3. In Task Manager, click File, click New Task, type explorer, and then click OK.

Would there be a way to automate this process by backing up the registry values and copying the user's custom ones in instead? The only thing left to automate would be the restart of explorer. Is it possible to stop and restart a process (eg. explorer.exe) using NSIS (or AutoIt, possibly)? This would also allow a user to take those icon behavior settings around to other computers, and would conceal which apps they were using.

This is just an idea, I don't know if it would work.
Any more ideas/suggestions?

John Bentley
John Bentley's picture
Offline
Last seen: 13 years 5 months ago
Developer
Joined: 2006-01-24 13:26
RegDelete("HKEY_CURRENT_USER
RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify", "IconStreams");
RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify", "PastIconStreams");
If MsgBox(0x4, "Warning", "All explorer windows will be closed. Would you like to continue.")  6 Then Exit;
ProcessClose("explorer.exe");
Run("explorer.exe");

[Pre tags added by moderator SL]

cowsay Moo
cowthink 'Dude, why are you staring at me.'

BrianAll
Offline
Last seen: 4 years 7 months ago
Joined: 2008-02-13 13:44
Sweet!

I think I'll try this out and make an app out of it. It would make clearing those icons a lot easier.
Thanks for that. Biggrin

Bruce Pascoe
Offline
Last seen: 11 years 3 weeks ago
Joined: 2006-01-15 16:14
...

Only bad thing is that if you set the icons to always show/hide (I set all the ones for my portable apps to always show), Windows won't remember that once the icon is deleted from the registry...

Also, I notice that the NSIS script above kills explorer and restarts it. Not the best idea, as killing explorer like that loses the positions of any recently moved desktop icons, and may cause some tray icons to disappear unless the app(s) that created them are programmed to deal with explorer restarting (many still aren't!)

rab040ma
Offline
Last seen: 6 months 3 days ago
Joined: 2007-08-27 13:35
Yeah, I'd tend to agree.

Yeah, I'd tend to agree.

What's the purpose for killing Explorer, did the Microsoft article say? If it is to clear Explorer's settings from memory, you'd do better (if on a computer at work or school) to restart the whole computer, or at least log off and back on (which restarts Explorer. You could have a the program clear those registry entries and log you off ... and dismount Truecrypt volumes, and run MRU-blaster, and securely erase everything in the TEMP directory, and ...

Have you checked whether those programs can be configured to not use the notification tray? Maybe that would eliminate the settings in the registry.

MC

wraithdu
Offline
Last seen: 9 years 7 months ago
Developer
Joined: 2007-06-27 20:22
I've researched this a

I've researched this a little before. It is actually necessary to kill explorer via Task Manager. It seems the icon settings are stored in memory and rewritten to the registry on logoff/shutdown. So even if you clear the reg entries, they're recreated. Killing explorer prevents the entries from being recreated, and is the only way to clear the cache.

m2
Offline
Last seen: 11 years 11 months ago
Joined: 2006-12-12 12:00
But you could follow also

But you could follow also this guide.

"Those people who think they know everything are a great annoyance to those of us who do." Asimov

Nathan9222
Nathan9222's picture
Offline
Last seen: 1 year 3 months ago
Developer
Joined: 2007-12-06 22:35
all u need to do is........

all u need to do to remove the registry without making a launcher is to make a new .reg file and do this.................

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify]
"BalloonTip"=dword:00000005:
Original key to add to registry now for it to delete do this


[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\TrayNotify]
"BalloonTip"=dword:00000005:
Instead just put a hyphen (-) in the beginning of the value, then just double click, click yes to add, but instead it wont add these values, it will delete them. Now all you would need would be some kind of .bat file or NSIS script to close and restart explorer.exe or you could just restart computer.

Found this info at Microsoft

An eye for an eye makes the whole world blind.
Mahatma Gandhi,
Indian political and spiritual leader (1869 - 1948)

wraithdu
Offline
Last seen: 9 years 7 months ago
Developer
Joined: 2007-06-27 20:22
Sure, but you still have to

Sure, but you still have to kill and restart explorer to make it work.

wraithdu
Offline
Last seen: 9 years 7 months ago
Developer
Joined: 2007-06-27 20:22
Nice find. But I think you

Nice find. But I think you need to forcibly terminate explorer so it doesn't get a chance to write the keys in the registry. I think properly closing it would still allow it to do so.

Bruce Pascoe
Offline
Last seen: 11 years 3 weeks ago
Joined: 2006-01-15 16:14
...

And hence, as I said, you also lose some other explorer-related customizations and run the risk of losing tray icons, as well. Okay for a "personal" launcher but not so good for a release-worthy app. Wink

Nathan9222
Nathan9222's picture
Offline
Last seen: 1 year 3 months ago
Developer
Joined: 2007-12-06 22:35
k

Here is my solution:

Open notepad or any similar program
" here is wat will close then restart explorer"
paste this in


@echo off
taskkill /f /IM explorer.exe
explorer.exe

then just save it as something like explorerclose.bat or *anything*.bat

delete the registry key, then just run the newly created batch file and it should work.

An eye for an eye makes the whole world blind.
Mahatma Gandhi,
Indian political and spiritual leader (1869 - 1948)

Log in or register to post comments