Ben
Ben

Reputation: 23

Determine what script/module a python instance is executing?

I'm writing a program to monitor a python script running. There will be multiple instances of this script, which is a server, running from different locations on the computer. My program will be monitoring to see that all instances that are being "watched" are up and running and will restart them as necessary.

The server script cannot be edited.

My problem is that the server process just shows up as the python executable, and I am unable to determine the location of the specific server script on the computer.

Is there anyway to determine what script is actually running on a specific python/pythonw.exe process? And also its path?

ENV: Windows only

Upvotes: 2

Views: 202

Answers (1)

Maksym Polshcha
Maksym Polshcha

Reputation: 18368

You can run the following command from the command line:

WMIC PROCESS get Caption,Commandline,Processid,ExecutablePath

This will show you which module is being executed.

Upvotes: 2

Related Questions