windowscmdprocesstitletasklist

Why cannot assign a window title to a background python process


I have a very simple python script inifinity_loop.py:

import time

i = 0
interval = 5
while True:
    print(f'I am counting {i} seconds')
    time.sleep(interval)
    i += interval

and I want to launch it from command line with a window title, so later I can find this process and its PID. This is how I launch the process:

start "MYPY" /B python infinity_loop.py

Then I try to find it via:

tasklist /v /fo csv /nh | sort

or more directly:

tasklist /v /fi "windowtitle eq MYPY" /fo csv /nh

But either way I cannot see the process with the given title. What am I missing?


Solution

  • By using the /B switch you told start to open the program without a command prompt window. No window, no window title - nothing to find.

    https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/start