Make old icon disappear from system tray automatically after SpeedFan restarts
Solution 1
I had the exact same problem, and fixed it with a simple change to my bat file and without having to install any other programs.
The problem is you are running taskkill with /f wich forces (hard) kills the task. If you kill it without the /f it sends a close signal to the application, the application exits cleanly and removes its system tray icon.
In my bat file I do two taskkill commands; the first without the /f and then again with the /f. If the first one works (which it usually should) then all is well and the system tray icon goes away. If for some reason the first one fails, the the second one will still kill it, although in that case the system tray icon would not be removed.
So, in your case, use:
taskkill /T /IM speedfan.exe
taskkill /F /T /IM speedfan.exe
Solution 2
Now for a proper answer.
Just use a simple AutoIt script instead of taskkill /F /IM
:
WinClose("SpeedFan")
You just need to make sure that "Minimize on close" is disabled in the SpeedFan configuration ("Options"-Tab).
I'm sorry if this is not a proper answer and I can't back it up with personal experience but have you even tried to find a solution?
My general approach would be to make virtual mouse movements or use some Windows-api calls to force windows to refresh the notification area.
I've never done something like that but after a few searches i arrived at this Google Search String: windows refresh icons "system tray" OR "notification area" autohotkey OR autoit
One good looking result: AHK - ow-to-refresh-system-tray-icons
Another one: autohotkey.com/board/topic/80624-notrayorphans/
(linked in the thread from above)
Other results (without autohotkey OR autoit
):
- refreshing-the-notification-area-system-tray
forum.lazarus.freepascal.org/index.php?topic=14847.0
-
blog.stephenklancher.com/2013/08/refreshing-the-notification-area-system-tray/
(with executable - but it doesn't seem to work on windows 8.1 with classic-shell)
There is a Possible Duplicate on SO (i remember seeing more but i can't seem to find them):
stackoverflow.com/questions/74723/can-you-send-a-signal-to-windows-explorer-to-make-it-refresh-the-systray-icons
Unfortunately i can't post more direct links and i would have preferred to write a comment instead of this 'answer'...
Related videos on Youtube
Matthew Wai
Updated on September 18, 2022Comments
-
Matthew Wai almost 2 years
@echo off taskkill /F /T /IM speedfan.exe start "" "C:\Program Files (x86)\SpeedFan\speedfan.exe" cls exit
I use the above commands in a .bat file to restart SpeedFan automatically each time after the computer wakes up from the sleep mode.
However, the old SpeedFan icon in the system tray will not automatically disappear when the new one appears. I have to manually move the cursor to the old icon so as to make it disappear. How can I make it disappear automatically?
I just found a simple solution: download NoTrayOrphans.exe from http://www.autohotkey.net/~Nazzal/Other/NoTrayOrphans.exe
My thanks to all of you for your help!
-
Ramhound over 8 yearskilling and restarting explorer.exe will accomplish what you want.
-
Matthew Wai over 8 yearsDo you mean C:\Windows\explorer.exe?
-
Ramhound over 8 yearsThere is only one explorer.exe on your system.
-
qasdfdsaq over 8 yearsYou can't. A program can only automatically remove its system tray icon if you shut it down cleanly. By forcing an exit via taskkill you are deliberately preventing the application having any opportunity to remove it.
-
Matthew Wai over 8 years
taskkill /F /T /IM explorer.exe
start "" "C:\Windows\explorer.exe"
explorer.exe does not start after being killed at my end. -
MarredCheese over 5 yearsYour NoTrayOrphans link is broken. I assume this is the same thing: autohotkey.com/board/topic/80624-notrayorphans
-
Synetech about 5 years@qasdfdsaq, you can remove dead icons by hovering the mouse over them. Matthew is looking for a way to automatically move the mouse over the SpeedFan icon so that Explorer removes it. (There's no practical way to do that, but it is possible to sweep the cursor across the whole notification area, but the hidden icons add a complication; it would have to be popped out and then swept).
-
Matthew Wai about 5 yearsThere is no need to solve the problem now because I do not use SpeedFan anymore. Thanks to all of you anyway.
-
-
Matthew Wai over 8 yearsI found a simple solution: download NoTrayOrphans.exe from autohotkey.net/~Nazzal/Other/NoTrayOrphans.exe
-
Limer over 8 years@matthew-wai - I'm suprised i didn't stumble over that one. Still, using
WinClose("SpeedFan")
instead oftaskkill /F /IM
seems cleaner in this case since SpeedFan wont be killed but properly closed. -
Matthew Wai over 8 years
WinClose("speedfan.exe")
doesn't work at my end, so I can only use NoTrayOrphans.exe, which I found after searching many relevant webpages. -
Limer over 8 years@matthew-wai: An AutoIt script with
WinClose("SpeedFan")
(without.exe
- it's the name of the window, not the executable) works perfectly for me but it requires admin rights (just astaskkill
). -
Matthew Wai over 8 years
WinClose("SpeedFan")
doesn't work either at my end. Nothing happens when it is run. -
Pierre.Vriens almost 6 yearsI do not get it