How to trap the event of a new process starting with wmi

gel geli at tasmail.com
Thu Jul 6 01:31:31 EDT 2006


Below is how it is down with vbscript.  What is the best way to convert
this to python?

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colMonitoredProcesses = objWMIService. _
    ExecNotificationQuery("select * from __instancecreationevent " _
        & " within 1 where TargetInstance isa 'Win32_Process'")
i = 0

Do While i = 0
    Set objLatestProcess = colMonitoredProcesses.NextEvent
    Wscript.Echo objLatestProcess.TargetInstance.Name
Loop




More information about the Python-list mailing list