Batch file leaves multiple instances after log off


  1. Posts : 66
    Windows 10
       #1

    Batch file leaves multiple instances after log off


    I use task scheduler to run some batch files every time I log on and unlock a user account to refresh certain software that tends to get tripped up often. My basic batch file reads like:

    File1.bat:
    start /min "" "<File2.bat"
    exit

    File2.bat
    <Do some things>
    exit

    The task scheduler runs FIle1.bat every log on or unlock, which in turn runs File2.bat. I do this to prevent the command prompt from popping up everytime.

    Problem is, I notice that some windows programs associated with the command prompt don't shut down, and, the next time the batch files run, they start new instances. The most obvious culprits are "Console Window Host" and "Windows Command Processor". I believe that "Performance Log Utility" is doing it too. Basically, everytime I log on and off or unlock my account, it adds another instance or two.

    Is there something I can add to my batch file that can change this? I would like to avoid having a second batch file run when I log out or lock the account that cleans this up.

    System Specs: Windows 10 Pro, Ryzen 5 3600x, AMD 590x graphics card, 16 GB 3600 mhz RAM, 500 GB SSD.
    Last edited by SSShadii; 15 Jun 2020 at 18:59.
      My Computer


  2. Posts : 16,180
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #2

    Hello @SSShadii,

    SSShadii said:
    Problem is, I notice that some windows programs associated with the command prompt don't shut down, and, the next time the batch files run, they start new instances.
    Are they always the same programs?
    If so, can't to use taskkill /f at the end of the script to force close them?

    I hope this helps!
      My Computer


  3. Posts : 66
    Windows 10
    Thread Starter
       #3

    OK, so I just did an experiment, where I turned off all my scheduled tasks and restarted. Apparently it isn't the batch files, windows is just doing this everytime I lock/unlock or log off/on. It adds another Windows Command Processor and Console Windows Host instance. If I use my computer the way I usually do, i.e. not restarting it for a day or two, and just suspending and locking/unlocking and logging off/on a lot, it builds up, to the extent that I checked my ram usage, and it was over 90%.

    This can't be normal behavior. What could be going on?
      My Computer


  4. Posts : 16,180
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #4

    Hello @SSShadii,

    System Specifications

    Please update your system [ hardware ] specifications => How to Fill in your System Specs at Ten Forums.
    It will help us to help you!

    Thanks.
      My Computer


  5. Posts : 66
    Windows 10
    Thread Starter
       #5

    System specs have been updated in the first post. I found a work around, but it is totally stupid. Since both these programs control the command prompt, I can only TASKKILL them at the end of a file as it causes the cmd running the file to crash out. So I kill all of the instances at the end of a batch file that runs after a log in or unlock, and then kill all of the instances at the end of a batch file that runs after the desktop is locked.

    I would much rather know why this happens as it is annoying that my system does this. The other file that just keeps starting new instances is logman.exe, which is a program logger I believe?
      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 10:59.
Find Us




Windows 10 Forums