I have a list of PID and need the Python script names. Is there a way to resolve the PID?
I tried it already with psutil
and subprocess
, but I just get 'python.exe' returned.
I have a list of PID and need the Python script names. Is there a way to resolve the PID?
I tried it already with psutil
and subprocess
, but I just get 'python.exe' returned.
You could solve this with WMIC:
wmic process get processid,commandline
or with a WMI query:
Get-WmiObject -Query "SELECT CommandLine FROM Win32_Process WHERE ProcessID = 1"
There is also a python WMI wrapper if you want to do this in python code: https://pypi.org/project/WMI/
Edit:
After some research, I have found out that it is possible to achieve this with psutils
too. Just invoke cmdline
on your process instance. -> https://psutil.readthedocs.io/en/latest/#psutil.Process.cmdline