' ------ KONFIGURACJA SKRYPTU ------
strProcess = "calc.exe"  ' nazwa obrazu monitorowanego procesu
strComputer = "."
' ------ KONIEC KONFIGURACJI ---------
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colProcesses = objWMI.ExecNotificationQuery(_ 
                     "select * from __instanceDeletionevent " _ 
                   & " within 2 where TargetInstance isa 'Win32_Process' " _
                   & " and TargetInstance.Name = '" & strProcess & "'")
do 
   set objProcess = colProcesses.NextEvent
   WScript.Echo "Zakoczono proces " & strProcess & _
                " (" & objProcess.TargetInstance.ProcessID & ")"
   intRC = objWMI.Get("Win32_Process").Create(strProcess, , , intProcessID)
   if intRC = 0 Then
      Wscript.Echo strProcess & " zosta uruchomiony. Identyfikator PID: " & intProcessID
   else
      Wscript.Echo strProcess & " nie zosta uruchomiony.  Kod bdu: " & intRC
   end if
loop
