Wednesday, July 6, 2011

WSH VBScript WMI Example using ExecNotificationQuery with __InstanceOperationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_O.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="vbscript">
<![CDATA[
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set objs = svc.ExecNotificationQuery("Select * From __InstanceOperationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function
]]>
</script>
</job>
</package>

WSH VBScript WMI Example using ExecNotificationQuery with __InstanceCreationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_C.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="vbscript">
<![CDATA[
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set objs = svc.ExecNotificationQuery("Select * From __InstanceCreationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function
]]>
</script>
</job>
</package>

WSH VBScript WMI Example using ExecNotificationQuery with __InstanceModificationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_M.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="vbscript">
<![CDATA[
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set objs = svc.ExecNotificationQuery("Select * From __InstanceModificationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function
]]>
</script>
</job>
</package>

WSH VBScript WMI Example using ExecNotificationQuery with __InstanceDeletionEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_D.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="vbscript">
<![CDATA[
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set objs = svc.ExecNotificationQuery("Select * From __InstanceDeletionEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function
]]>
</script>
</job>
</package>

WSH VBScript WMI Example using ExecNotificationQuery with __InstanceCreationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_C.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="vbscript">
<![CDATA[
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set objs = svc.ExecNotificationQuery("Select * From __InstanceCreationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function
]]>
</script>
</job>
</package>

WSH VBScript WMI Example using ExecQuery

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsexecquery.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="vbscript">
<![CDATA[
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set objs = svc.ExecQuery("Select * From Win32_Process")
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function
]]>
</script>
</job>
</package>

WSH VBScript WMI Example Using Instancesof

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstancesof.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="vbscript">
<![CDATA[
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set objs = svc.InstancesOf("Win32_Process")
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function
]]>
</script>
</job>
</package>

WSH VBScript WMI Example Using Instances

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstances.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="vbscript">
<![CDATA[
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set ob = svc.Get("Win32_Process")
Set objs = ob.Instances_
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function
]]>
</script>
</job>
</package>

WSH Ruby WMI Example Using ExecNotificationQuery With __InstanceOperationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_O.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="ruby">
<![CDATA[
require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceOperationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
mystr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

]]>
</script>
</job>
</package>

WSH Ruby WMI Example Using ExecNotificationQuery With __InstanceModificationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_M.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="ruby">
<![CDATA[
require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceModificationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
mystr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

]]>
</script>
</job>
</package>

WSH Ruby WMI Example Using ExecNotificationQuery With __InstanceDeletionEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_D.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="ruby">
<![CDATA[
require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceDeletionEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
mystr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

]]>
</script>
</job>
</package>

WSH Ruby WMI Example Using ExecNotificationQuery With __InstanceCreationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_C.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="ruby">
<![CDATA[
require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceCreationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
mystr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

]]>
</script>
</job>
</package>

WSH Ruby WMI Example Using Execquery

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsexecquery.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="ruby">
<![CDATA[
require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecQuery("Select * From Win32_Process")
mystr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

]]>
</script>
</job>
</package>

WSH Ruby WMI Example Using InstancesOf

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstancesof.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="ruby">
<![CDATA[
require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.InstancesOf("Win32_Process")
mystr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

]]>
</script>
</job>
</package>

WSH Ruby WMI Example Using Instances

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstances.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="ruby">
<![CDATA[
require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
ob = svc.Get("Win32_Process")
objs = ob.Instances
mystr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

]]>
</script>
</job>
</package>

WSH Python WMI Example using ExecNotificationQuery with __InstanceOperationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_O.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="python">
<![CDATA[
import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceOperationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  
]]>
</script>
</job>
</package>

WSH Python WMI Example using ExecNotificationQuery with __InstanceModificationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_M.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="python">
<![CDATA[
import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceModificationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  
]]>
</script>
</job>
</package>

WSH Python WMI Example using ExecNotificationQuery with __InstanceDeletionEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_D.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="python">
<![CDATA[
import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceDeletionEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  
]]>
</script>
</job>
</package>

WSH Python WMI Example using ExecNotificationQuery with __InstanceCreationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_C.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="python">
<![CDATA[
import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceCreationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  
]]>
</script>
</job>
</package>

WSH Python WMI Example using ExecQuery

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsexecquery.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="python">
<![CDATA[
import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecQuery("Select * From Win32_Process")
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  
]]>
</script>
</job>
</package>

WSH Python WMI Example using InstancesOf

You can download the scripting program for generating these scripts at:
http://www.planetmps.com/wmiscriptsinstancesof.html
<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="Python">
<![CDATA[
import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.InstancesOf("Win32_Process")
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  
]]>
</script>
</job>
</package>

WSH Python WMI Example using Instances

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstances.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="python">
<![CDATA[
import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
ob = svc.Get("Win32_Process")
objs = ob.instances_
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  
]]>
</script>
</job>
</package>

WSH Perlscript WMI Example using ExecNotificationQuery with __InstanceOperationEvent

You can download the scripting program for generating these scripts at:
http://www.planetmps.com/wmiscriptsENQ_O.html
<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="perlscript">
<![CDATA[
use Win32::OLE( 'in' );
my $locator = Win32::OLE->CreateObject("WBemScripting.SWbemLocator");
my $svc = $locator->ConnectServer();
my $objs = $svc->ExecNotificationQuery("Select * From __InstanceOperationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
my $mystr = "";
foreach my $obj (in($objs)
{
    foreach my $prop (in($obj->Properties_)
    {
    }
last;
}
]]>
</script>
</job>
</package>

WSH Perlscript WMI Example using ExecNotificationQuery with __InstanceModificationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_M.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="perlscript">
<![CDATA[
use Win32::OLE( 'in' );
my $locator = Win32::OLE->CreateObject("WBemScripting.SWbemLocator");
my $svc = $locator->ConnectServer();
my $objs = $svc->ExecNotificationQuery("Select * From __InstanceModificationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
my $mystr = "";
foreach my $obj (in($objs)
{
    foreach my $prop (in($obj->Properties_)
    {
    }
last;
}
]]>
</script>
</job>
</package>

WSH Perlscript WMI Example using ExecNotificationQuery with __InstanceDeletionEvent

You can download the scripting program for generating these scripts at:
http://www.planetmps.com/wmiscriptsENQ_D.html
<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="perlscript">
<![CDATA[
use Win32::OLE( 'in' );
my $locator = Win32::OLE->CreateObject("WBemScripting.SWbemLocator");
my $svc = $locator->ConnectServer();
my $objs = $svc->ExecNotificationQuery("Select * From __InstanceDeletionEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
my $mystr = "";
foreach my $obj (in($objs)
{
    foreach my $prop (in($obj->Properties_)
    {
    }
last;
}
]]>
</script>
</job>
</package>

WSH Perlscript WMI Example using ExecNotificationQuery with __InstanceCreationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_C.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="perlscript">
<![CDATA[
use Win32::OLE( 'in' );
my $locator = Win32::OLE->CreateObject("WBemScripting.SWbemLocator");
my $svc = $locator->ConnectServer();
my $objs = $svc->ExecNotificationQuery("Select * From __InstanceCreationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
my $mystr = "";
foreach my $obj (in($objs)
{
    foreach my $prop (in($obj->Properties_)
    {
    }
last;
}
]]>
</script>
</job>
</package>

WSH Perlscript WMI Example using ExecQuery

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsexecquery.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="perlscript">
<![CDATA[
use Win32::OLE( 'in' );
my $locator = Win32::OLE->CreateObject("WBemScripting.SWbemLocator");
my $svc = $locator->ConnectServer();
$objs = $svc->ExecQuery("Select * From Win32_Process");
my $mystr = "";
foreach my $obj (in($objs)
{
    foreach my $prop (in($obj->Properties_)
    {
    }
last;
}
]]>
</script>
</job>
</package>

Tuesday, July 5, 2011

WSH Perlscript WMI Example using InstancesOf

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstancesof.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="perlscript">
<![CDATA[
use Win32::OLE( 'in' );
my $locator = Win32::OLE->CreateObject("WBemScripting.SWbemLocator");
my $svc = $locator->ConnectServer();
$objs = $svc->InstancesOf("Win32_Process");
my $mystr = "";
foreach my $obj (in($objs)
{
    foreach my $prop (in($obj->Properties_)
    {
    }
last;
}
]]>
</script>
</job>
</package>

WSH Perlscript WMI Example using Instances

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstances.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="perlscript">
<![CDATA[
use Win32::OLE( 'in' );
my $locator = Win32::OLE->CreateObject("WBemScripting.SWbemLocator");
my $svc = $locator->ConnectServer();
$ob = $svc->Get("Win32_Process");
$objs = $ob->Instances_;
my $mystr = "";
foreach my $obj (in($objs)
{
    foreach my $prop (in($obj->Properties_)
    {
    }
last;
}
]]>
</script>
</job>
</package>

WSH JScript WMI Example using ExecNotificationQuery with __InstanceOperationEvent

You can download the scripting program for generating these scripts at:
http://www.planetmps.com/wmiscriptsENQ_O.html
<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="jscript">
<![CDATA[
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = locator.ConnectServer(".", "root\cimv2");
svc.Security_.AuthenticationLevel = 0;
svc.Security_.ImpersonationLevel = 3;
var objs = svc.ExecNotificationQuery("Select * From __InstanceOperationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
var objEnum = new Enumerator(objs);
var mystr = new String();
for(;!objEnum.atEnd();objEnum.moveNext())
{
     var obj = objEnum.item();
     var propEnum = new Enumerator(obj.Properties_);
     var mystr = new String();
     for(;!propEnum.atEnd();propEnum.moveNext())
     {
     }
break;
}
]]>
</script>
</job>
</package>

WSH JScript WMI Example using ExecNotificationQuery with __InstanceModificationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_M.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="jscript">
<![CDATA[
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = locator.ConnectServer(".", "root\cimv2");
svc.Security_.AuthenticationLevel = 0;
svc.Security_.ImpersonationLevel = 3;
var objs = svc.ExecNotificationQuery("Select * From __InstanceModificationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
var objEnum = new Enumerator(objs);
var mystr = new String();
for(;!objEnum.atEnd();objEnum.moveNext())
{
     var obj = objEnum.item();
     var propEnum = new Enumerator(obj.Properties_);
     var mystr = new String();
     for(;!propEnum.atEnd();propEnum.moveNext())
     {
     }
break;
}
]]>
</script>
</job>
</package>

WSH JScript WMI Example using ExecNotificationQuery with __InstanceDeletionEvent

You can download the scripting program for generating these scripts at:
http://www.planetmps.com/wmiscriptsENQ_D.html
<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="jscript">
<![CDATA[
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = locator.ConnectServer(".", "root\cimv2");
svc.Security_.AuthenticationLevel = 0;
svc.Security_.ImpersonationLevel = 3;
var objs = svc.ExecNotificationQuery("Select * From __InstanceDeletionEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
var objEnum = new Enumerator(objs);
var mystr = new String();
for(;!objEnum.atEnd();objEnum.moveNext())
{
     var obj = objEnum.item();
     var propEnum = new Enumerator(obj.Properties_);
     var mystr = new String();
     for(;!propEnum.atEnd();propEnum.moveNext())
     {
     }
break;
}
]]>
</script>
</job>
</package>

WSH JScript WMI Example using ExecNotificationQuery with __InstanceCreationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_C.html


<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="jscript">
<![CDATA[
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = locator.ConnectServer(".", "root\cimv2");
svc.Security_.AuthenticationLevel = 0;
svc.Security_.ImpersonationLevel = 3;
var objs = svc.ExecNotificationQuery("Select * From __InstanceCreationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
var objEnum = new Enumerator(objs);
var mystr = new String();
for(;!objEnum.atEnd();objEnum.moveNext())
{
     var obj = objEnum.item();
     var propEnum = new Enumerator(obj.Properties_);
     var mystr = new String();
     for(;!propEnum.atEnd();propEnum.moveNext())
     {
     }
break;
}
]]>
</script>
</job>
</package>

WSH JScript WMI Example using ExecQuery

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsexecquery.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="jscript">
<![CDATA[
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = locator.ConnectServer(".", "root\cimv2");
svc.Security_.AuthenticationLevel = 0;
svc.Security_.ImpersonationLevel = 3;
var objs = svc.ExecQuery("Select * From Win32_Process");
var objEnum = new Enumerator(objs);
var mystr = new String();
for(;!objEnum.atEnd();objEnum.moveNext())
{
     var obj = objEnum.item();
     var propEnum = new Enumerator(obj.Properties_);
     var mystr = new String();
     for(;!propEnum.atEnd();propEnum.moveNext())
     {
     }
break;
}
]]>
</script>
</job>
</package>

WSH JScript WMI Example using Instances

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstances.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="jscript">
<![CDATA[
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = locator.ConnectServer(".", "root\cimv2");
svc.Security_.AuthenticationLevel = 0;
svc.Security_.ImpersonationLevel = 3;
var ob = svc.Get("Win32_Process");
var objs = ob.Instances_;
var objEnum = new Enumerator(objs);
var mystr = new String();
for(;!objEnum.atEnd();objEnum.moveNext())
{
     var obj = objEnum.item();
     var propEnum = new Enumerator(obj.Properties_);
     var mystr = new String();
     for(;!propEnum.atEnd();propEnum.moveNext())
     {
     }
break;
}
]]>
</script>
</job>
</package>

WSH Javascript WMI Example using ExecNotificationQuery with __InstanceOperationEvent

You can download the scripting program for generating these scripts at:
http://www.planetmps.com/wmiscriptsENQ_O.html
<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="javascript">
<![CDATA[
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = locator.ConnectServer(".", "root\cimv2");
svc.Security_.AuthenticationLevel = 0;
svc.Security_.ImpersonationLevel = 3;
var objs = svc.ExecNotificationQuery("Select * From __InstanceOperationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
var objEnum = new Enumerator(objs);
var mystr = new String();
for(;!objEnum.atEnd();objEnum.moveNext())
{
     var obj = objEnum.item();
     var propEnum = new Enumerator(obj.Properties_);
     var mystr = new String();
     for(;!propEnum.atEnd();propEnum.moveNext())
     {
     }
break;
}
]]>
</script>
</job>
</package>

WSH Javascript WMI Example using ExecNotificationQuery with __InstanceModificationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_M.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="javascript">
<![CDATA[
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = locator.ConnectServer(".", "root\cimv2");
svc.Security_.AuthenticationLevel = 0;
svc.Security_.ImpersonationLevel = 3;
var objs = svc.ExecNotificationQuery("Select * From __InstanceModificationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
var objEnum = new Enumerator(objs);
var mystr = new String();
for(;!objEnum.atEnd();objEnum.moveNext())
{
     var obj = objEnum.item();
     var propEnum = new Enumerator(obj.Properties_);
     var mystr = new String();
     for(;!propEnum.atEnd();propEnum.moveNext())
     {
     }
break;
}
]]>
</script>
</job>
</package>

WSH Javascript WMI Example using ExecNotificationQuery with __InstanceDeletionEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_D.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="javascript">
<![CDATA[
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = locator.ConnectServer(".", "root\cimv2");
svc.Security_.AuthenticationLevel = 0;
svc.Security_.ImpersonationLevel = 3;
var objs = svc.ExecNotificationQuery("Select * From __InstanceDeletionEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
var objEnum = new Enumerator(objs);
var mystr = new String();
for(;!objEnum.atEnd();objEnum.moveNext())
{
     var obj = objEnum.item();
     var propEnum = new Enumerator(obj.Properties_);
     var mystr = new String();
     for(;!propEnum.atEnd();propEnum.moveNext())
     {
     }
break;
}
]]>
</script>
</job>
</package>

WSH Javascript WMI Example using ExecNotificationQuery with __InstanceCreationEvent

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="javascript">
<![CDATA[
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = locator.ConnectServer(".", "root\cimv2");
svc.Security_.AuthenticationLevel = 0;
svc.Security_.ImpersonationLevel = 3;
var objs = svc.ExecNotificationQuery("Select * From __InstanceCreationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
var objEnum = new Enumerator(objs);
var mystr = new String();
for(;!objEnum.atEnd();objEnum.moveNext())
{
     var obj = objEnum.item();
     var propEnum = new Enumerator(obj.Properties_);
     var mystr = new String();
     for(;!propEnum.atEnd();propEnum.moveNext())
     {
     }
break;
}
]]>
</script>
</job>
</package>

WSH Javascript WMI Example using ExecQuery

You can download the scripting program for generating these scripts at:
http://www.planetmps.com/wmiscriptsexecquery.html
<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="javascript">
<![CDATA[
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = locator.ConnectServer(".", "root\cimv2");
svc.Security_.AuthenticationLevel = 0;
svc.Security_.ImpersonationLevel = 3;
var objs = svc.ExecQuery("Select * From Win32_Process");
var objEnum = new Enumerator(objs);
var mystr = new String();
for(;!objEnum.atEnd();objEnum.moveNext())
{
     var obj = objEnum.item();
     var propEnum = new Enumerator(obj.Properties_);
     var mystr = new String();
     for(;!propEnum.atEnd();propEnum.moveNext())
     {
     }
break;
}
]]>
</script>
</job>
</package>

WSH Javascript WMI Example using InstancesOf

You can download the scripting program for generating these scripts at:
http://www.planetmps.com/wmiscriptsinstancesof.html
<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="javascript">
<![CDATA[
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = locator.ConnectServer(".", "root\cimv2");
svc.Security_.AuthenticationLevel = 0;
svc.Security_.ImpersonationLevel = 3;
var objs = svc.InstancesOf("Win32_Process");
var objEnum = new Enumerator(objs);
var mystr = new String();
for(;!objEnum.atEnd();objEnum.moveNext())
{
     var obj = objEnum.item();
     var propEnum = new Enumerator(obj.Properties_);
     var mystr = new String();
     for(;!propEnum.atEnd();propEnum.moveNext())
     {
     }
break;
}
]]>
</script>
</job>
</package>

WSH Javascript WMI Example using Instances

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstances.html

<?xml version='1.0' encoding='iso-8859-1'?>
<package>
<job>
<script language="javascript">
<![CDATA[
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
var svc = locator.ConnectServer(".", "root\cimv2");
svc.Security_.AuthenticationLevel = 0;
svc.Security_.ImpersonationLevel = 3;
var ob = svc.Get("Win32_Process");
var objs = ob.Instances_;
var objEnum = new Enumerator(objs);
var mystr = new String();
for(;!objEnum.atEnd();objEnum.moveNext())
{
     var obj = objEnum.item();
     var propEnum = new Enumerator(obj.Properties_);
     var mystr = new String();
     for(;!propEnum.atEnd();propEnum.moveNext())
     {
     }
break;
}
]]>
</script>
</job>
</package>

VBScript WMI Example using ExecNotificationQuery with __InstanceOperationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_O.html

Const wbemFlagReturnImmediately = &H10
Const wbemFlagForwardOnly = &H20
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set objs = svc.ExecNotificationQuery("Select * From __InstanceOperationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function

VBScript WMI Example using ExecNotificationQuery with __InstanceModificationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_M.html

Const wbemFlagReturnImmediately = &H10
Const wbemFlagForwardOnly = &H20
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set objs = svc.ExecNotificationQuery("Select * From __InstanceModificationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function

VBScript WMI Example using ExecNotificationQuery with __InstanceDeletionEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_D.html

Const wbemFlagReturnImmediately = &H10
Const wbemFlagForwardOnly = &H20
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set objs = svc.ExecNotificationQuery("Select * From __InstanceDeletionEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function

VBScript WMI Example using ExecNotificationQuery with __InstanceCreationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_C.html

Const wbemFlagReturnImmediately = &H10
Const wbemFlagForwardOnly = &H20
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set objs = svc.ExecNotificationQuery("Select * From __InstanceCreationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function

VBScript WMI Example using ExecQuery

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsexecquery.html

Const wbemFlagReturnImmediately = &H10
Const wbemFlagForwardOnly = &H20
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set objs = svc.ExecQuery("Select * From Win32_Process")
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function

VBScript WMI Example using InstancesOf

You can download the scripting program for generating these scripts at:
http://www.planetmps.com/wmiscriptsinstancesof.html
Const wbemFlagReturnImmediately = &H10
Const wbemFlagForwardOnly = &H20
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set objs = svc.InstancesOf("Win32_Process")
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function

VBScript WMI Example using Instances

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstances.html

Const wbemFlagReturnImmediately = &H10
Const wbemFlagForwardOnly = &H20
Dim l
Dim svc
Dim ob
Dim objs
Dim obj
Dim prop
Dim tstr
Set l = CreateObject("WbemScripting.SWbemLocator")
Set svc = l.ConnectServer(".", "root\cimv2")
Set ob = svc.Get("Win32_Process")
Set objs = ob.Instances_
For each obj in objs
    For each prop in obj.Properties_
        tstr = tstr & prop.Name & " = " & GetValue(prop.Name, obj) & vbcrlf
    Next
WScript.Echo(tstr)
tstr = ""
Next
function GetValue(Name, obj)
   Dim tempstr
   Dim pname
   Dim pos
   pname = Name & " = "
   pos = InStr(obj.GetObjectText_, pname)
   If pos Then
      pos = pos + Len(pname)
      tempstr = Mid(obj.GetObjectText_, pos, Len(obj.GetObjectText_))
      pos = InStr(tempstr, ";")
      tempstr = Mid(tempstr, 1, pos - 1)
      tempstr = Replace(tempstr, Chr(34), "")
      tempstr = Replace(tempstr, "{", "")
      tempstr = Replace(tempstr, "}", "")
      If (obj.Properties_(Name).CIMtype = 101 And Len(tempstr) > 14) Then
         GetValue = Mid(tempstr, 5, 2) + "/" + _
                    Mid(tempstr, 7, 2) + "/" + _
                    Mid(tempstr, 1, 4) + " " + _
                    Mid(tempstr, 9, 2) + ":" + _
                    Mid(tempstr, 11, 2) + ":" + _
                    Mid(tempstr, 13, 2)
      Else
         GetValue = tempstr
      End If
   Else
      GetValue = ""
   End If
End Function

Ruby WMI Example using ExecNotificationQuery with __InstanceOperationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_O.html

require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceOperationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
tstr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

Ruby WMI Example using ExecNotificationQuery with __InstanceModificationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_M.html

require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceModificationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
tstr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

Ruby WMI Example using ExecNotificationQuery with __InstanceDeletionEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_D.html

require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceDeletionEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
tstr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

Ruby WMI Example using ExecNotificationQuery with __InstanceCreationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_C.html

require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceCreationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
tstr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

Ruby WMI Example using ExecQuery

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsexecquery.html

require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecQuery("Select * From Win32_Process")
tstr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

Ruby WMI Example using InstancesOf

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstancesof.html

require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.InstancesOf("Win32_Process")
tstr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

Ruby WMI Example using Instances

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstances.html

require("win32ole")
i=0
locator = WIN32OLE.new("WbemScripting.SWbemLocator")
svc = locator.connectserver()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
ob = svc.Get("Win32_Process")
objs = ob.Instances
tstr = ""
objs.each{ |obj|
    obj.Properties_.each{ |prop|

End
End

Rexx WMI Example using ExecNotificationQuery with __InstanceOperationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_O.html

locator = .OLEObject~new("WbemScripting.SWbemLocator")
svc = locator~ConnectServer(".", "root\cimv2")
svc~Security_~AuthenticationLevel = 0
svc~Security_~ImpersonationLevel = 3
objs = svc~ExecNotificationQuery("Select * From __InstanceOperationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
do obj over objs
    do prop over obj~Properties_
    end
exit
end

Rexx WMI Example using ExecNotificationQuery with __InstanceModificationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_M.html

locator = .OLEObject~new("WbemScripting.SWbemLocator")
svc = locator~ConnectServer(".", "root\cimv2")
svc~Security_~AuthenticationLevel = 0
svc~Security_~ImpersonationLevel = 3
objs = svc~ExecNotificationQuery("Select * From __InstanceModificationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
do obj over objs
    do prop over obj~Properties_
    end
exit
end

Rexx WMI Example using ExecNotificationQuery with __InstanceDeletionEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_D.html

locator = .OLEObject~new("WbemScripting.SWbemLocator")
svc = locator~ConnectServer(".", "root\cimv2")
svc~Security_~AuthenticationLevel = 0
svc~Security_~ImpersonationLevel = 3
objs = svc~ExecNotificationQuery("Select * From __InstanceDeletionEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
do obj over objs
    do prop over obj~Properties_
    end
exit
end

Rexx WMI Example using ExecNotificationQuery with __InstanceCreationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_C.html

locator = .OLEObject~new("WbemScripting.SWbemLocator")
svc = locator~ConnectServer(".", "root\cimv2")
svc~Security_~AuthenticationLevel = 0
svc~Security_~ImpersonationLevel = 3
objs = svc~ExecNotificationQuery("Select * From __InstanceCreationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
do obj over objs
    do prop over obj~Properties_
    end
exit
end

Rexx WMI Example using ExecQuery

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsexecquery.html

locator = .OLEObject~new("WbemScripting.SWbemLocator")
svc = locator~ConnectServer(".", "root\cimv2")
svc~Security_~AuthenticationLevel = 0
svc~Security_~ImpersonationLevel = 3
objs = svc~ExecQuery("Select * From Win32_Process")
do obj over objs
    do prop over obj~Properties_
    end
exit
end

Rexx WMI Example using InstancesOf

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstancesof.html

locator = .OLEObject~new("WbemScripting.SWbemLocator")
svc = locator~ConnectServer(".", "root\cimv2")
svc~Security_~AuthenticationLevel = 0
svc~Security_~ImpersonationLevel = 3
objs = svc~InstancesOf("Win32_Process")
do obj over objs
    do prop over obj~Properties_
    end
exit
end

Rexx WMI Example using Instances

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstances.html

locator = .OLEObject~new("WbemScripting.SWbemLocator")
svc = locator~ConnectServer(".", "root\cimv2")
svc~Security_~AuthenticationLevel = 0
svc~Security_~ImpersonationLevel = 3
ob = svc~Get("Win32_Process")
objs = ob~Instances
do obj over objs
    do prop over obj~Properties_
    end
exit
end

Python WMI Example using ExecNotificationQuery with __InstanceOperationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_O.html

import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceOperationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  

Python WMI Example using ExecNotificationQuery with __InstanceModificationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_M.html

import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceModificationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  

Python WMI Example using ExecNotificationQuery with __InstanceDeletionEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_D.html

import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceDeletionEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  

Python WMI Example using ExecNotificationQuery with __InstanceCreationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_C.html

import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecNotificationQuery("Select * From __InstanceCreationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'")
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  

Python WMI Example using ExecQuery

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsexecquery.html

import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.ExecQuery("Select * From Win32_Process")
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  

Python WMI Example using Instances

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstances.html

import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
ob = svc.Get("Win32_Process")
objs = ob.instances_
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  

Python WMI Example using InstancesOf

You can download the scripting program for generating these scripts at:
http://www.planetmps.com/wmiscriptsinstancesof.html
import win32com.client
import string
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
svc = locator.ConnectServer()
svc.Security_.AuthenticationLevel = 0
svc.Security_.ImpersonationLevel = 3
objs = svc.InstancesOf("Win32_Process")
mystr = ""
for obj in Objs:
   for prop in Objs.Properties_:
  
  
   break
  

PHP WMI Example using ExecNotificationQuery with __InstanceOperationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_O.html

com_load_typelib("Microsoft WMI Scripting V1.2 Library");
$locator = new COM("WbemScripting.SWbemLocator");
$svc = $locator->ConnectServer();
$objs = $svc->ExecNotificationQuery("Select * From __InstanceOperationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
$objs = $objs->Next($objs->Count);
foreach($objs as $obj)
{
   foreach($prop as $obj->Properties_)
   {
   }
 last;
}

PHP WMI Example using ExecNotificationQuery with __InstanceModificationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_M.html

com_load_typelib("Microsoft WMI Scripting V1.2 Library");
$locator = new COM("WbemScripting.SWbemLocator");
$svc = $locator->ConnectServer();
$objs = $svc->ExecNotificationQuery("Select * From __InstanceModificationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
$objs = $objs->Next($objs->Count);
foreach($objs as $obj)
{
   foreach($prop as $obj->Properties_)
   {
   }
 last;
}

PHP WMI Example using ExecNotificationQuery with __InstanceDeletionEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_D.html

com_load_typelib("Microsoft WMI Scripting V1.2 Library");
$locator = new COM("WbemScripting.SWbemLocator");
$svc = $locator->ConnectServer();
$objs = $svc->ExecNotificationQuery("Select * From __InstanceDeletionEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
$objs = $objs->Next($objs->Count);
foreach($objs as $obj)
{
   foreach($prop as $obj->Properties_)
   {
   }
 last;
}

PHP WMI Example using ExecNotificationQuery with __InstanceCreationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_C.html

com_load_typelib("Microsoft WMI Scripting V1.2 Library");
$locator = new COM("WbemScripting.SWbemLocator");
$svc = $locator->ConnectServer();
$objs = $svc->ExecNotificationQuery("Select * From __InstanceCreationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
$objs = $objs->Next($objs->Count);
foreach($objs as $obj)
{
   foreach($prop as $obj->Properties_)
   {
   }
 last;
}

PHP WMI Example using ExecQuery

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsexecquery.html

com_load_typelib("Microsoft WMI Scripting V1.2 Library");
$locator = new COM("WbemScripting.SWbemLocator");
$svc = $locator->ConnectServer();
$objs = $svc->ExecQuery("Select * From Win32_Process");
foreach($objs as $obj)
{
   foreach($prop as $obj->Properties_)
   {
   }
 last;
}

PHP WMI Example using InstancesOf

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstancesof.html

com_load_typelib("Microsoft WMI Scripting V1.2 Library");
$locator = new COM("WbemScripting.SWbemLocator");
$svc = $locator->ConnectServer();
$objs = $svc->InstancesOf("Win32_Process");
foreach($objs as $obj)
{
   foreach($prop as $obj->Properties_)
   {
   }
 last;
}

PHP WMI Example using Instances

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsinstances.html

com_load_typelib("Microsoft WMI Scripting V1.2 Library");
$locator = new COM("WbemScripting.SWbemLocator");
$svc = $locator->ConnectServer();
$ob = $svc->Get("Win32_Process");
$objs = $ob->Instances_;
foreach($objs as $obj)
{
   foreach($prop as $obj->Properties_)
   {
   }
 last;
}

Monday, July 4, 2011

Perlscript WMI Example using ExecNotificationQuery with __InstanceOperationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_O.html

use Win32::OLE( 'in' );
my $locator = Win32::OLE->CreateObject("WBemScripting.SWbemLocator");
my $svc = $locator->ConnectServer();
my $objs = $svc->ExecNotificationQuery("Select * From __InstanceOperationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
my $mystr = "";
foreach my $obj (in($objs)
{
    foreach my $prop (in($obj->Properties_)
    {
    }
last;
}

Perlscript WMI Example using ExecNotificationQuery with __InstanceModificationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_M.html

use Win32::OLE( 'in' );
my $locator = Win32::OLE->CreateObject("WBemScripting.SWbemLocator");
my $svc = $locator->ConnectServer();
my $objs = $svc->ExecNotificationQuery("Select * From __InstanceModificationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
my $mystr = "";
foreach my $obj (in($objs)
{
    foreach my $prop (in($obj->Properties_)
    {
    }
last;
}

Perlscript WMI Example using ExecNotificationQuery with __InstanceModificationEvent

You can download the scripting program for generating these scripts at:

http://www.planetmps.com/wmiscriptsENQ_M.html

use Win32::OLE( 'in' );
my $locator = Win32::OLE->CreateObject("WBemScripting.SWbemLocator");
my $svc = $locator->ConnectServer();
my $objs = $svc->ExecNotificationQuery("Select * From __InstanceModificationEvent WITHIN 1 where targetInstance ISA 'Win32_Process'");
my $mystr = "";
foreach my $obj (in($objs)
{
    foreach my $prop (in($obj->Properties_)
    {
    }
last;
}