using cmd/batch to kill and restart a process resetsnotification area?


  1. Posts : 181
    10, server 2016, server2012
       #1

    using cmd/batch to kill and restart a process resetsnotification area?


    as thread/question title shows, whenever I use a batch file to run simple command lines such as:

    Code:
    taskkill /F /IM abc.exe
    start "" "C:\Users\Administrator\abc.exe" :0 -clipboard -multiwindow

    to kill a program and starts it, it resets notification setting for that program. well actually instead of reset, it creates a new entry..

    window taskbar -> notification area-> customize notification -> creates another entry of the same program.

    while another entry of that program is created, it is created with default "only show notification" while the original program icon is still there with my settings which is "show icons and notification". However if I use task manager to kill task manually and reopen it with a shortcut of that program, it doesn't do this.

    how can I fix this? am I missing something that I need to add in the commandline?
      My Computer


  2. Posts : 456
    Windows 10
       #2

    Since you are using the option: -multiwindow I would guess that there is more than 1 instance of the program runing thus you can try to finish the whole process tree with /t:

    taskkill /F /T /IM abc.exe
      My Computer


  3. Posts : 181
    10, server 2016, server2012
    Thread Starter
       #3

    ricardobohner said:
    Since you are using the option: -multiwindow I would guess that there is more than 1 instance of the program runing thus you can try to finish the whole process tree with /t:
    hey, I gave it a try but didn't work.

    I just realized that it seems window notification area still shows the program icon even when task is closed. I'd have to move or hover my mouse over the closed program icon under notification area to make those icons go away. If I dont do this, the new started program will have issue as I stated in my OP, but if I clear those icons before the commandline restarts them, this issue doesnt come up.

    I guess my next question is, is there a way to clear notification area (not force reset entire thing) but only to clear the closed program.
      My Computer


  4. Posts : 16,949
    Windows 10 Home x64 Version 22H2 Build 19045.4170
       #4

    The limitations & peculiarities of the Built-in Admin account have never been documented. I suggest you stop using it for routine purposes and switch to an account you have created yourself.

    All the best,
    Denis
      My Computer


  5. Posts : 181
    10, server 2016, server2012
    Thread Starter
       #5

    Try3 said:
    The limitations & peculiarities of the Built-in Admin account have never been documented. I suggest you stop using it for routine purposes and switch to an account you have created yourself.Denis
    it is an account, I simply copy the link and took out the username replace it with administrator for less confusion. I could just use (useraccount) instead but its the samething. so how to go about fixing this?
      My Computer


  6. Posts : 1
    Windows 11 / macOS Monterry / Manjaro
       #6

    I know I'm a little late to the party, but still want to offer my two cents.

    Short answer: Remove the "/F" flag after TASKKILL.

    When you close a program normally (e.g., by manually closing all the windows or by using TASKKILL without /F), the program sends a signal to the OS to redraw the notification area before it actually quits. However, if you use "TASKKILL /F", the OS terminates the program immediately without allowing it to wrap up. This is as if the program crashes by itself, not having a chance to tell the OS to remove the notification icon.

    On the other hand, I can see why "/F" can be desirable, since TASKKILL alone may not be sufficient to close the program (for example, when the program hangs for whatever reason), and can ruin your subsequent commands in your script. Adding "/F" makes sure the program will be terminated, but the downside is you get a phantom/orphan notification icon.

    So what if you have to use the "/F" flag?

    In that case you can rely on Windows API "NotififyIcon.Dispose()" to remove the icon. There are also many wrapped executables than can do this, feel free to Google it. Here is an example: TrayIconBuster

    I hope this is helpful for your problem.
    Last edited by jiangzhenjerry; 02 Feb 2022 at 19:53.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 23:41.
Find Us




Windows 10 Forums