[Python] stop a python multi threads application via batch script on windows

Discussão em 'Python' iniciado por Stack, Janeiro 21, 2025.

  1. Stack

    Stack Membro Participativo

    I have a python application. The application has multiple threads running, to perform multiple tasks at the same time. Some of the tasks are for example monitoring different folders.

    I need to start the application via the command line and also stop the application via the windows command lines.

    I run via command line with a simple command on windows. the command to run the application:

    python myapplication.py


    starting application obviousely not a problem. My problem is how to stop the application.

    I have found many reference to taskkill, as the best option. However taskkill is no finding any process with myapplication name. how do I stop this application via commandline?

    this is the command I did to stop

    taskkill /F /IM "myapplication" /T


    and I get the following error:

    ERROR: The process "myapplication" not found.


    I have tried multiple variation of it like bellow and many others,but none is working. I get the error that the process "" not found.

    taskkill /F /IM "myapplication.py" /T
    taskkill /IM "myapplication.py" /F


    does anyone has an idea?

    Continue reading...

Compartilhe esta Página