Skip to content
Advertisement

How do I know what python scripts are running in Windows?

As I mentioned above, is there a way to find out what python scripts are running in Windows?

Advertisement

Answer

If you have PowerShell installed, you can get that information by using Windows Management Instrumentation (WMI) and some scripting…

Open the PowerShell and use these two lines, it should could you started:

> $pys = get-wmiobject Win32_process -filter "Name='python.exe'"
> $pys.CommandLine

This will show you the command line arguments used to start the python process, which should contain the name of the main script file ran by Python. For a test program I have, it displays the following:

"C:Python27python.exe" "D:Projectswait.py"

In case you have multiple scripts running, the var $pys will be an array, so to access it you’ll have to access the individual elements like so:

> $pys[0].CommandLine

EDIT: Or you could do it all in one single line, again in PowerShell:

 > get-wmiobject Win32_process -filter "Name='python.exe'" | foreach -process {$_.CommandLine}

I hope you get the general idea.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement