Monitor Process in Python?

前端 未结 3 844
遥遥无期
遥遥无期 2020-12-17 03:35

I think this is a pretty basic question, but here it is anyway.

I need to write a python script that checks to make sure a process, say notepad.exe, is running. If t

3条回答
  •  清酒与你
    2020-12-17 03:57

    There are a couple of options,

    1: the more crude but obvious would be to do some text processing against:

    os.popen('tasklist').read()
    

    2: A more involved option would be to use pywin32 and research the win32 APIs to figure out what processes are running.

    3: WMI (I found this just now), and here is a vbscript example of how to query the machine for processes through WMI.

提交回复
热议问题