You have created several python scripts and running them simultaneously. You decide you want to kill first script you run. As always, you open Windows Task Manager but then you see several python.exe processes. Which one is the script you want to kill? You do not have clue. If you recognize this situation – The following script I wrote allows to overcome this issue and change name of python processes to unique one.

Overview

The idea is basically based on the fact that Windows Task Manager display the image name of the process (the name of the binary file which is executed by the process). If we copy the python.exe to a unique name and then running it, we will see the newlly copied image name in Windows Task Manager. Since this file is a copy python.exe, we can invoke it as usual to execute any python script.

The script

Create a new file named python-by-name.bat in the python directory with the following contents:

python-by-name.bat
set PYTHON_HOME=%~dp0
set PYTHON_NAME=%1.exe
copy "%PYTHON_HOME%\python.exe" "%PYTHON_HOME%\%PYTHON_NAME%"
set args=%*
set args=%args:* =%
"%PYTHON_HOME%\%PYTHON_NAME%" %args%

Usage

Now, Let’s see how we can use this above batch to distinguish between your python scripts.

Suppose you want to run the following command:

python <arguments>

Invoke the following command instead:

python-by-name my_unique_name <arguments>

Now, my_unique_name.exe process will appear in Windows Task Manager instead of python.exe.