Scripts listed in this section are fully documented in Understanding WMI Scripting (ISBN 1555582664) along with the WMI aspects and the scripting techniques they use. Beyond the learning curve they represent, they also offer useful functionalities to pursue our WMI discovery process. That's the reason why they are used many times throughout this second volume dedicated to WMI. The most experienced people in WMI, using this second volume on a standalone basis, can refer to this section to gather more information about these scripts. Again, the scripts are given for reference only. People interested in getting more information about the scripts must refer to Understanding WMI Scripting (ISBN 1555582664).
Sample 4.6: Retrieving all instances of the Win32_Service class with their properties
1:<?xml version="1.0"?> .: 8:<package> 9: <job> ..: 13: <object prog reference="true"/> 14: 15: <script language="VBscript"> 16: <![CDATA[ ..: 20: Const cComputerName = "LocalHost" 21: Const cWMINameSpace = "root/cimv2" 22: Const cWMIClass = "Win32_Service" ..: 27: objWMILocator.Security_.AuthenticationLevel = wbemAuthenticationLevelDefault 28: objWMILocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate 29: Set objWMIServices = objWMILocator.ConnectServer(cComputerName, cWMINameSpace, "", "") 30: Set objWMIInstances = objWMIServices.InstancesOf (cWMIClass) 31: 32: For Each objWMIInstance in objWMIInstances 33: WScript.Echo objWMIInstance.Name & " (" & objWMIInstance.Description & ")" 34: WScript.Echo " AcceptPause=" & objWMIInstance.AcceptPause 35: WScript.Echo " AcceptStop=" & objWMIInstance.AcceptStop 36: WScript.Echo " Caption=" & objWMIInstance.Caption 37: WScript.Echo " Checkpoint=" & objWMIInstance.Checkpoint 38: WScript.Echo " CreationClassName=" & objWMIInstance.CreationClassName 39: WScript.Echo " Description=" & objWMIInstance.Description 40: WScript.Echo " DesktopInteract=" & objWMIInstance.DesktopInteract 41: WScript.Echo " DisplayName=" & objWMIInstance.DisplayName 42: WScript.Echo " ErrorControl=" & objWMIInstance.ErrorControl 43: WScript.Echo " ExitCode=" & objWMIInstance.ExitCode 44: WScript.Echo " InstallDate=" & objWMIInstance.InstallDate 45: WScript.Echo " Name=" & objWMIInstance.Name 46: WScript.Echo " PathName=" & objWMIInstance.PathName 47: WScript.Echo " Process ServiceSpecificExitCode=" & objWMIInstance.ServiceSpecificExitCode 49: WScript.Echo " ServiceType=" & objWMIInstance.ServiceType 50: WScript.Echo " Started=" & objWMIInstance.Started 51: WScript.Echo " StartMode=" & objWMIInstance.StartMode 52: WScript.Echo " StartName=" & objWMIInstance.StartName 53: WScript.Echo " State=" & objWMIInstance.State 54: WScript.Echo " Status=" & objWMIInstance.Status 55: WScript.Echo " SystemCreationClassName=" & objWMIInstance.SystemCreationClassName 56: WScript.Echo " SystemName=" & objWMIInstance.SystemName 57: WScript.Echo " Tag WaitHint=" & objWMIInstance.WaitHint 59: Next ..: 64: ]]> 65: </script> 66: </job> 67:</package>
Sample 4.14: Setting one read/write property of a Win32_Registry class instance directly
1:<?xml version="1.0"?> .: 8:<package> 9: <job> ..: 13: <object prog reference="true"/> 14: 15: <script language="VBscript"> 16: <![CDATA[ ..: 20: Const cComputerName = "LocalHost" 21: Const cWMINameSpace = "root/cimv2" 22: Const cWMIClass = "Win32_Registry" 23: Const cWMIInstance = "Microsoft Windows.NET Server|J:\WINDOWS|\Device\Harddisk0\Partition8" ..: 28: objWMILocator.Security_.AuthenticationLevel = wbemAuthenticationLevelDefault 29: objWMILocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate 30: Set objWMIServices = objWMILocator.ConnectServer(cComputerName, cWMINameSpace, "", "") 31: Set objWMIInstance = objWMIServices.Get (cWMIClass & "='" & cWMIInstance & "'") 32: 33: WScript.Echo objWMIInstance.Name & " (" & objWMIInstance.Description & ")" 34: 35: Wscript.Echo "Current registry size is: " & objWMIInstance.ProposedSize & " MB." 36: 37: objWMIInstance.ProposedSize = objWMIInstance.ProposedSize + 10 38: objWMIInstance.Put_ (wbemChangeFlagUpdateOnly Or wbemFlagReturnWhenComplete) 39: 40: Wscript.Echo "Current registry size is: " & objWMIInstance.ProposedSize & " MB." ..: 45: ]]> 46: </script> 47: </job> 48:</package>
Sample 4.15: Setting one read/write property of a Win32_Registry class instance indirectly
1:<?xml version="1.0"?> .: 8:<package> 9: <job> ..: 13: <object prog reference="true"/> 14: 15: <script language="VBscript"> 16: <![CDATA[ ..: 20: Const cComputerName = "LocalHost" 21: Const cWMINameSpace = "root/cimv2" 22: Const cWMIClass = "Win32_Registry" 23: Const cWMIInstance = "Microsoft Windows.NET Server|J:\WINDOWS|\Device\Harddisk0\Partition8" ..: 29: objWMILocator.Security_.AuthenticationLevel = wbemAuthenticationLevelDefault 30: objWMILocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate 31: Set objWMIServices = objWMILocator.ConnectServer(cComputerName, cWMINameSpace, "", "") 32: Set objWMIInstance = objWMIServices.Get (cWMIClass & "='" & cWMIInstance & "'") 33: 34: WScript.Echo objWMIInstance.Name & " (" & objWMIInstance.Description & ")" 35: 36: Set objWMIPropertySet = objWMIInstance.Properties_ 37: 38: Wscript.Echo "Current registry size is: " & objWMIPropertySet.Item("ProposedSize") & " MB." 39: 40: objWMIPropertySet.Item("ProposedSize") = objWMIPropertySet.Item("ProposedSize") + 10 41: objWMIInstance.Put_ (wbemChangeFlagUpdateOnly Or wbemFlagReturnWhenComplete) 42: 43: Wscript.Echo "Current registry size is: " & objWMIPropertySet.Item("ProposedSize") & " MB." ..: 50: ]]> 51: </script> 52: </job> 53:</package>
Sample 4.30: A generic routine to display the SWbemPropertySet object
.: 6:' --------------------------------------------------------------------------------------------- 7:Function DisplayProperties (objWMIInstance, intIndent) ..: 14: Set objWMIPropertySet = objWMIInstance.Properties_ 15: For Each objWMIProperty In objWMIPropertySet 16: 17: boolCIMKey = objWMIProperty.Qualifiers_.Item("key").Value 18: If Err.Number Then 19: Err.Clear 20: boolCIMKey = False 21: End If 22: If boolCIMKey Then 23: strCIMKey = "*" 24: Else 25: strCIMKey = "" 26: End If 27: 28: If Not IsNull (objWMIProperty.Value) Then 29: If objWMIProperty.CIMType = wbemCimtypeObject Then 30: If objWMIProperty.IsArray Then 31: For Each varElement In objWMIProperty.Value 32: WScript.Echo Space (intIndent) & strCIMKey & objWMIProperty.Name & _ 33: " (" & GetCIMSyntaxText (objWMIProperty.CIMType) & ")" 34: DisplayProperties varElement, intIndent + 2 35: Next 36: Else 37: WScript.Echo Space (intIndent) & strCIMKey & objWMIProperty.Name & _ 38: " (" & GetCIMSyntaxText (objWMIProperty.CIMType) & ")" 39: DisplayProperties objWMIProperty.Value, intIndent + 2 40: End If 41: Else 42: If objWMIProperty.IsArray Then 43: For Each varElement In objWMIProperty.Value 44: WScript.Echo Space (intIndent) & strCIMKey & objWMIProperty.Name & _ 45: " (" & GetCIMSyntaxText (objWMIProperty.CIMType) & ") = " & _ 46: varElement 47: Next 48: Else 49: If objWMIProperty.Name = "TIME_CREATED" Then 50: objWMIDateTime.SetFileTime (objWMIProperty.Value) 51: 52: WScript.Echo Space (intIndent) & strCIMKey & objWMIProperty.Name & _ 53: " (" & GetCIMSyntaxText (objWMIProperty.CIMType) & ") = " & _ 54: objWMIDateTime.GetVarDate (True) & _ 55: " (" & objWMIDateTime.Value & ")" 56: Else 57: If objWMIProperty.CIMType = wbemCimtypeDatetime Then 58: objWMIDateTime.Value = objWMIProperty.Value 59: 60: WScript.Echo Space (intIndent) & strCIMKey & objWMIProperty.Name & _ 61: " (" & GetCIMSyntaxText (objWMIProperty.CIMType) & ") = " & _ 62: objWMIDateTime.GetVarDate (True) & _ 63: " (" & objWMIProperty.Value & ")" 64: Else 65: WScript.Echo Space (intIndent) & strCIMKey & objWMIProperty.Name & _ 66: " (" & GetCIMSyntaxText (objWMIProperty.CIMType) & ") = " & _ 67: objWMIProperty.Value 68: End If 69: End If 70: End If 71: End If 72: Else 73: WScript.Echo Space (intIndent) & strCIMKey & objWMIProperty.Name & _ 74: " (" & GetCIMSyntaxText (objWMIProperty.CIMType) & ") = (null)" 75: End If 76: Next ..: 79:End Function 80: 81:' --------------------------------------------------------------------------------------------- 82:Function GetCIMSyntaxText (intCIMType) 83: 84: Select Case intCIMType 85: ' Signed 16-bit integer 86: Case 2 87: GetCIMSyntaxText = "wbemCimtypeSint16" 88: ' Signed 32-bit integer 89: Case 3 90: GetCIMSyntaxText = "wbemCimtypeSint32" 91: ' 32-bit real number 92: Case 4 93: GetCIMSyntaxText = "wbemCimtypeReal32" 94: ' 64-bit real number 95: Case 5 96: GetCIMSyntaxText = "wbemCimtypeReal64" 97: ' String 98: Case 8 99: GetCIMSyntaxText = "wbemCimtypeString" 100: ' Boolean value 101: Case 11 102: GetCIMSyntaxText = "wbemCimtypeBoolean" 103: ' CIM object 104: Case 13 105: GetCIMSyntaxText = "wbemCimtypeObject" 106: ' Signed 8-bit integer 107: Case 16 108: GetCIMSyntaxText = "wbemCimtypeSint8" 109: ' Unsigned 8-bit integer 110: Case 17 111: GetCIMSyntaxText = "wbemCimtypeUint8" 112: ' Unsigned 16-bit integer 113: Case 18 114: GetCIMSyntaxText = "wbemCimtypeUint16" 115: ' Unsigned 32-bit integer 116: Case 19 117: GetCIMSyntaxText = "wbemCimtypeUint32" 118: ' Signed 64-bit integer 119: Case 20 120: GetCIMSyntaxText = "wbemCimtypeSint64" 121: ' Unsigned 64-bit integer 122: Case 21 123: GetCIMSyntaxText = "wbemCimtypeUint64" 124: ' Date/time value 125: Case 101 126: GetCIMSyntaxText = "wbemCimtypeDatetime" 127: ' Reference to a CIM object. 128: Case 102 129: GetCIMSyntaxText = "wbemCimtypeReference" 130: ' 16-bit character 131: Case 103 132: GetCIMSyntaxText = "wbemCimtypeChar16" 133: End Select 134: 135:End Function
Sample 4.31: Browsing the namespaces to find class definitions
1:<?xml version="1.0"?> .: 8:<package> 9: <job> ..: 13: <runtime> ..: 18: </runtime> 19: 20: <script language="VBScript" src="/books/2/679/1/html/2/..\Functions\DisplayInstanceProperties.vbs" /> 21: <script language="VBScript" src="/books/2/679/1/html/2/..\Functions\TinyErrorHandler.vbs" /> 22: 23: <object prog reference="true"/> 24: <object prog /> 25: 26: <script language="VBscript"> 27: <![CDATA[ ..: 31: Const cComputerName = "LocalHost" 32: Const cWMINameSpace = "Root" 33: Const cWMINamespaceClass = "__NAMESPACE" 34: Const cWMIClass = "__EventProviderRegistration" ..: 40: ' -------------------------------------------------------------------------------- 41: ' Parse the command line parameters 42: If WScript.Arguments.Unnamed.Count = 0 Then 43: strWMIClass = InputBox ("Enter the WMI Class to examine: ", _ 44: "WMI Class:", _ 45: cWMIClass) 46: 47: If Len (strWMIClass) = 0 Then 48: WScript.Arguments.ShowUsage() 49: WScript.Quit 50: End If 51: Else 52: strWMIClass = WScript.Arguments.Unnamed.Item(0) 53: End If 54: strWMIClass = Ucase (strWMIClass) 55: 56: strUserID = WScript.Arguments.Named("User") 57: If Len(strUserID) = 0 Then strUserID = "" 58: 59: strPassword = WScript.Arguments.Named("Password") 60: If Len(strPassword) = 0 Then strPassword = "" 61: 62: strComputerName = WScript.Arguments.Named("Machine") 63: If Len(strComputerName) = 0 Then strComputerName = cComputerName 64: 65: DisplayNameSpaces cWMINameSpace, strWMIClass, strUserID, strPassword, strComputerName 66: 67: ' -------------------------------------------------------------------------------------- 68: Function DisplayNameSpaces (ByVal strWMINameSpace, _ 69: ByVal strWMIClass, _ 70: ByVal strUserID, _ 71: ByVal strPassword, _ 72: ByVal strComputerName) ..: 82: objWMILocator.Security_.AuthenticationLevel = wbemAuthenticationLevelDefault 83: objWMILocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate 84: Set objWMIServices = objWMILocator.ConnectServer(strComputerName, _ 85: strWMINameSpace, _ 86: strUserID, _ 87: strPassword) ..: 90: Set objWMIInstance = objWMIServices.Get (strWMIClass) 91: If Err.Number Then 92: Err.Clear 93: Else 94: WScript.Echo strWMINameSpace 95: DisplayProperties objWMIInstance, 2 ..: 97: End If 98: 99: Set objWMINSInstances = objWMIServices.InstancesOf (cWMINamespaceClass, _ wbemQueryFlagShallow) 100: For Each objWMINSInstance in objWMINSInstances 101: DisplayNameSpaces strWMINameSpace & "/" & objWMINSInstance.Name, _ 102: strWMIClass, strUserID, strPassword, strComputerName 103: Next ...: 108: End Function 109: 110: ]]> 111: </script> 112: </job> 113:</package>
Sample 4.32: A Windows Script File self-documenting the CIM repository classes in an Excel sheet
1:<?xml version="1.0"?> .: 8:<package> 9: <job> ..: 13: <runtime> ..: 31: </runtime> 32: 33: <script language="VBScript" src="/books/2/679/1/html/2/..\Functions\TinyErrorHandler.vbs" /> 34: 35: <object prog reference="true"/> 36: <object prog /> 37: <object prog /> 38: 39: <script language="VBscript"> 40: <![CDATA[ ..: 44: Const cLevelClassOnly = 1 45: Const cLevelClassWithProps = 2 46: Const cLevelClassWithPropsAndMethods = 3 47: Const cLevelClassWithPropsAndMethodsWithInParams = 4 48: Const cLevelClassWithPropsAndMethodsWithInOutParams = 5 49: Const cLevelClassWithPropsQAndMethodsQWithParamsQ = 6 50: 51: Const Black = 1 52: Const Silver = 15 53: Const Aqua1 = 42 54: Const Aqua2 = 8 55: Const White1 = 2 56: Const White2 = 40 57: Const White3 = 19 58: Const Yellow = 27 59: 60: Const cOriginPosition = 9 61: Const cQualifierPosition = 10 62: 63: Const cComputerName = "LocalHost" 64: Const cWMINameSpace = "Root/CIMv2" ..: 81: ' -------------------------------------------------------------------------------- 82: ' Parse the command line parameters 83: If WScript.Arguments.Unnamed.Count = 0 Then 84: strWMIClass = InputBox ("Enter the WMI Class to examine: ", _ 85: "WMI Class:", _ 86: "Win32_Service") 87: 88: If Len (strWMIClass) = 0 Then 89: WScript.Arguments.ShowUsage() 90: WScript.Quit 91: End If 92: Else 93: strWMIClass = WScript.Arguments.Unnamed.Item(0) 94: End If 95: ' strWMIClass = Ucase (strWMIClass) 96: 97: strUserID = WScript.Arguments.Named("User") 98: If Len(strUserID) = 0 Then strUserID = "" 99: 100: strPassword = WScript.Arguments.Named("Password") 101: If Len(strPassword) = 0 Then strPassword = "" 102: 103: strComputerName = WScript.Arguments.Named("Machine") 104: If Len(strComputerName) = 0 Then strComputerName = cComputerName 105: 106: strWMINameSpace = WScript.Arguments.Named("NameSpace") 107: If Len(strWMINameSpace) = 0 Then strWMINameSpace = cWMINameSpace 108: strWMINameSpace = UCase (strWMINameSpace) 109: 110: intExplorationDepth = Cint (WScript.Arguments.Named("Level")) 111: If intExplorationDepth = 0 Then 112: intExplorationDepth = cLevelClassWithPropsAndMethodsWithInOutParams 113: End If 114: 115: boolSubClass = WScript.Arguments.Named("Sub") 116: boolOrigin = Not WScript.Arguments.Named("Origin") 117: 118: ' -------------------------------------------------------------------------------- 119: ' Prepare an Excel worksheet 120: ' Make it visible, don't hide it because for the save, the user will be prompted! 121: objXL.Visible = True 122: 123: ' Open Excel and start an empty workbook 124: objXL.Workbooks.Add 125: 126: ' Put the cursor on the A1 cell 127: objXL.ActiveSheet.range("A1").Activate 128: objXL.ActiveSheet.Name = Mid (strWMIClass, 1, 31) 129: 130: objXL.Columns("A:Z").Font.Name = "Tahoma" 131: objXL.Columns("A:Z").IndentLevel = 0 132: objXL.Columns("A:Z").VerticalAlignment = 2 133: 134: If intExplorationDepth > cLevelClassWithPropsAndMethodsWithInOutParams Then 135: 136: ' Format the XL Sheet 137: objXL.Columns("A:I").ColumnWidth = 5 138: objXL.Columns("J").ColumnWidth = 22 139: objXL.Columns("K").ColumnWidth = 16 140: objXL.Columns("L").ColumnWidth = 22 141: objXL.Columns("M:Z").ColumnWidth = 7 142: objXL.Rows("1").Orientation = 90 143: objXL.Rows("1").VerticalAlignment = 3 144: objXL.Rows("1").HorizontalAlignment = 3 145: 146: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & objXL.ActiveCell.Row).Font.Bold = True 147: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & objXL.ActiveCell.Row).Font.Size = 16 148: 149: intX = cOriginPosition 150: ' Origin 151: objXL.Activecell.Offset(0, intX).Value = "Origin" 152: 153: intX = cQualifierPosition 154: ' Name 155: objXL.Activecell.Offset(0, intX).Value = "Qualifier Name" 156: ' Value 157: objXL.Activecell.Offset(0, intX + 1).Value = "Value" 158: ' Amended 159: objXL.Activecell.Offset(0, intX + 2).Value = "Amended" 160: ' Local 161: objXL.Activecell.Offset(0, intX + 3).Value = "Local" 162: ' Overridable 163: objXL.Activecell.Offset(0, intX + 4).Value = "Overridable" 164: ' Propagates to instance 165: objXL.Activecell.Offset(0, intX + 5).Value = "Propagates to instance" 166: ' Propagates to subclass 167: objXL.Activecell.Offset(0, intX + 6).Value = "Propagates to subclass" 168: 169: intX = 0 170: objXL.Activecell.Offset(1, 0).Activate 171: End If 172: 173: ' -------------------------------------------------------------------------------- 174: ' Connect to WMI 175: objWMILocator.Security_.AuthenticationLevel = wbemAuthenticationLevelDefault 176: objWMILocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate 177: Set objWMIServices = objWMILocator.ConnectServer(strComputerName, _ 178: strWMINameSpace, _ 179: strUserID, _ 180: strPassword) ...: 183: DisplayClasses intX, objWMIServices, strWMIClass ...: 187: ' -------------------------------------------------------------------------------- 188: objXL.ActiveSheet.range("A1").Activate 189: 190: ' Save & Close the Workbook. If file exists, user will be prompted. 191: objXL.Workbooks.Application.ActiveWorkbook.SaveAs _ 192: (WshShell.CurrentDirectory & "\" & objXL.ActiveSheet.Name) 193: objXL.Workbooks.close 194: objXL.Quit 195: 196: ' -------------------------------------------------------------------------------------- 197: Function DisplayClasses (ByVal intX, ByVal objWMIServices, ByVal strWMIClass) ...: 209: Set objWMIInstance = objWMIServices.Get (strWMIClass, wbemFlagUseAmendedQualifiers) ...: 212: If intExplorationDepth > cLevelClassOnly Then 213: ' Format the XL sheet 214: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Font.Bold = True 215: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Font.Size = 18 216: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Font.ColorIndex = White1 217: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Interior.ColorIndex = Black 218: 219: ' List the classes 220: ' Class 221: objXL.Activecell.Offset(0, 0).Value = "Class" 222: objXL.Activecell.Offset(1, 0).Activate 223: End If 224: 225: WScript.Echo Space (intX) & strWMIClass 226: objXL.Activecell.Offset(0, intX).Value = strWMIClass 227: 228: If intExplorationDepth > cLevelClassOnly Then 229: ' Format the XL sheet 230: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Interior.ColorIndex = Aqua1 231: End If 232: 233: If intExplorationDepth > cLevelClassWithPropsAndMethodsWithInOutParams Then 234: DisplayQualifiers (objWMIInstance.Qualifiers_) 235: End If 236: 237: objXL.Activecell.Offset(1, 0).Activate 238: 239: If intExplorationDepth > cLevelClassOnly Then 240: Set objWMIPropertySet = objWMIInstance.Properties_ 241: If objWMIPropertySet.Count Then 242: intX = intX + 1 243: 244: ' Format the XL Sheet 245: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Font.Bold = True 246: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Font.Size = 14 247: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Interior.ColorIndex = Silver 248: 249: ' List the properties of the Class 250: ' Properties 251: objXL.Activecell.Offset(0, intX).Value = "Properties" 252: objXL.Activecell.Offset(1, 0).Activate 253: 254: For Each objWMIProperty In objWMIPropertySet 255: 256: If (objWMIProperty.Origin = strWMIClass) Or boolOrigin Then 257: objXL.Activecell.Offset(0, intX).Value = objWMIProperty.Name 258: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Interior.ColorIndex = Aqua2 259: If intExplorationDepth < cLevelClassWithPropsQAndMethodsQWithParamsQ Then 260: objXL.Activecell.Offset(0, intX + 3).Value = _ objWMIProperty.Qualifiers_.Item("CIMTYPE").Value 261: 262: boolCIMKey = objWMIProperty.Qualifiers_.Item("key").Value 263: If Err.Number Then 264: Err.Clear 265: boolCIMKey = False 266: End If 267: If boolCIMKey Then 268: objXL.Activecell.Offset(0, intX + 4).Value = "(Key)" 269: End If 270: 271: boolCIMRead = objWMIProperty.Qualifiers_.Item("read").Value 272: If Err.Number Then 273: Err.Clear 274: boolCIMRead = False 275: End If 276: 277: boolCIMWrite = objWMIProperty.Qualifiers_.Item("write").Value 278: If Err.Number Then 279: Err.Clear 280: boolCIMWrite = False 281: End If 282: 283: If boolCIMRead ANd boolCIMWrite Then 284: objXL.Activecell.Offset(0, intX + 5).Value = "Read/Write" 285: Else 286: If boolCIMRead Then 287: objXL.Activecell.Offset(0, intX + 5).Value = "Read" 288: End If 289: If boolCIMWrite Then 290: objXL.Activecell.Offset(0, intX + 5).Value = "Write" 291: End If 292: End If 293: 294: strDescription = objWMIProperty.Qualifiers_.Item("Description").Value 295: If Err.Number Then 296: Err.clear 297: Else 298: objXL.Activecell.Offset(0, intX + 6).Value = strDescription 299: objXL.Activecell.Offset(0, intX + 6).WrapText = False 300: End If 301: 302: End If 303: If intExplorationDepth > cLevelClassWithPropsAndMethodsWithInOutParams Then 304: objXL.Activecell.Offset(0, cOriginPosition).Value = _ objWMIProperty.Origin 305: DisplayQualifiers (objWMIProperty.Qualifiers_) 306: End If 307: 308: objXL.Activecell.Offset(1, 0).Activate 309: End If 310: Next 311: End If ...: 314: If intExplorationDepth > cLevelClassWithProps Then 315: Set objWMIMethodSet = objWMIInstance.Methods_ 316: If objWMIMethodSet.Count Then 317: ' Format the XL Sheet 318: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Font.Bold = True 319: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Font.Size = 14 320: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Interior.ColorIndex = Silver 321: 322: ' List the methods of the Class 323: ' Properties 324: objXL.Activecell.Offset(0, intX).Value = "Methods" 325: objXL.Activecell.Offset(1, 0).Activate 326: 327: For Each objWMIMethod In objWMIMethodSet 328: If (objWMIMethod.Origin = strWMIClass) Or boolOrigin Then 329: objXL.Activecell.Offset(0, intX).Value = objWMIMethod.Name 330: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Interior.ColorIndex = White2 331: If intExplorationDepth > cLevelClassWithPropsAndMethodsWithInOutParams Then 332: objXL.Activecell.Offset(0, cOriginPosition).Value = _ objWMIMethod.Origin 333: DisplayQualifiers (objWMIMethod.Qualifiers_) 334: Else 335: strDescription = objWMIMethod.Qualifiers_.Item("Description").Value 336: If Err.Number Then 337: Err.clear 338: Else 339: objXL.Activecell.Offset(0, intX + 6).Value = strDescription 340: objXL.Activecell.Offset(0, intX + 6).WrapText = False 341: End If 342: End If 343: objXL.Activecell.Offset(1, 0).Activate 344: 345: If intExplorationDepth > cLevelClassWithPropsAndMethods Then 346: Set objWMIObject = objWMIMethod.InParameters 347: Set objWMIPropertySet = objWMIObject.Properties_ 348: If Err.Number = 0 Then 349: intX = intX + 1 350: 351: ' Format the XL Sheet 352: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Font.Bold = True 353: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Font.Size = 10 354: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Interior.ColorIndex = Silver 355: 356: ' List the methods of the Class 357: ' Parameters 358: objXL.Activecell.Offset(0, intX).Value = "Input parameter(s)" 359: If intExplorationDepth > cLevelClassWithPropsAndMethodsWithInOutParams Then 360: DisplayQualifiers (objWMIObject.Qualifiers_) 361: End If 362: objXL.Activecell.Offset(1, 0).Activate 363: 364: For Each objWMIProperty In objWMIPropertySet 365: 366: If (objWMIProperty.Origin = strWMIClass) Or boolOrigin Then 367: objXL.Activecell.Offset(0, intX).Value = _ objWMIProperty.Name 368: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Interior.ColorIndex = White3 369: If intExplorationDepth = cLevelClassWithPropsAndMethodsWithInParams Or _ 370: intExplorationDepth = cLevelClassWithPropsAndMethodsWithInOutParams Then 371: objXL.Activecell.Offset(0, intX + 2).Value = _ objWMIProperty.Qualifiers_.Item("CIMTYPE").Value 372: strDescription = _ objWMIProperty.Qualifiers_.Item("Description").Value 373: If Err.Number Then 374: Err.clear 375: Else 376: objXL.Activecell.Offset(0, intX + 5).Value = _ strDescription 377: objXL.Activecell.Offset(0, intX + 5).WrapText = _ False 378: End If 379: End If 380: If intExplorationDepth > cLevelClassWithPropsAndMethodsWithInOutParams Then 381: objXL.Activecell.Offset(0, cOriginPosition).Value = _ objWMIProperty.Origin 382: DisplayQualifiers (objWMIProperty.Qualifiers_) 383: End If 384: objXL.Activecell.Offset(1, 0).Activate 385: End If 386: 387: Next 388: intX = intX - 1 389: Else 390: Err.Clear 391: End If ...: 394: End If 395: 396: If intExplorationDepth > cLevelClassWithPropsAndMethodsWithInParams Then 397: Set objWMIObject = objWMIMethod.OutParameters 398: Set objWMIPropertySet = objWMIObject.Properties_ 399: If Err.Number = 0 Then 400: intX = intX + 1 401: 402: ' Format the XL Sheet 403: objXL.Range("A" & objXL.Activecell.Row & ":Z" & _ objXL.ActiveCell.Row).Font.Bold = True 404: objXL.Range("A" & objXL.Activecell.Row & ":Z" & _ objXL.Activecell.Row).Font.Size = 10 405: objXL.Range("A" & objXL.Activecell.Row & ":Z" & _ objXL.ActiveCell.Row).Interior.ColorIndex = Silver 406: 407: ' List the methods of the Class 408: ' Parameters 409: objXL.Activecell.Offset(0, intX).Value = "Output parameter(s)" 410: If intExplorationDepth > cLevelClassWithPropsAndMethodsWithInOutParams Then 411: DisplayQualifiers (objWMIObject.Qualifiers_) 412: End If 413: objXL.Activecell.Offset(1, 0).Activate 414: 415: For Each objWMIProperty In objWMIPropertySet 416: 417: If (objWMIProperty.Origin = strWMIClass) Or boolOrigin Then 418: objXL.Activecell.Offset(0, intX).Value = _ objWMIProperty.Name 419: objXL.Range("A" & objXL.ActiveCell.Row & ":Z" & _ objXL.ActiveCell.Row).Interior.ColorIndex = Yellow 420: If intExplorationDepth = cLevelClassWithPropsAndMethodsWithInOutParams Then 421: objXL.Activecell.Offset(0, intX + 2).Value = _ objWMIProperty.Qualifiers_.Item("CIMTYPE").Value 422: strDescription = _ objWMIProperty.Qualifiers_.Item("Description").Value 423: If Err.Number Then 424: Err.clear 425: Else 426: objXL.Activecell.Offset(0, intX + 5).Value = _ strDescription 427: objXL.Activecell.Offset(0, intX + 5).WrapText = _ False 428: End If 429: End If 430: If intExplorationDepth > cLevelClassWithPropsAndMethodsWithInOutParams Then 431: objXL.Activecell.Offset(0, cOriginPosition).Value = _ objWMIProperty.Origin 432: DisplayQualifiers (objWMIProperty.Qualifiers_) 433: End If 434: objXL.Activecell.Offset(1, 0).Activate 435: End If 436: 437: Next 438: intX = intX - 1 439: Else 440: Err.Clear 441: End If ...: 444: End If 445: End If 446: 447: Next 448: End If ...: 450: End If ...: 454: intX = intX - 1 455: End If 456: 457: If boolSubClass Then 458: Set objWMISubClasses = objWMIServices.SubClassesOf (strWMIClass, _ 459: wbemQueryFlagShallow) 460: For Each objWMISubClass in objWMISubClasses 461: DisplayClasses intX + 1, objWMIServices, objWMISubClass.Path_.RelPath 462: Next ...: 464: End If 465: 466: End Function 467: 468: ' --------------------------------------------------------------------------------- 469: Function DisplayQualifiers (objWMIQualifiers) ...: 478: intX = cQualifierPosition 479: 480: For Each objWMIQualifier In objWMIQualifiers 481: objXL.Activecell.Offset(1, 0).Activate 482: objXL.Activecell.Offset(0, intX).Value = objWMIQualifier.Name 483: If IsArray (objWMIQualifier.Value) Then 484: For Each varElement In objWMIQualifier.Value 485: If Len (objXL.Activecell.Offset(0, intX + 1).Value) = 0 Then 486: objXL.Activecell.Offset(0, intX + 1).Value = varElement 487: Else 488: objXL.Activecell.Offset(0, intX + 1).Value = _ objXL.Activecell.Offset(0, intX + 1).Value & _ 489: Chr(10) & _ 490: varElement 491: End If 492: If Ucase (objWMIQualifier.Name) = "DESCRIPTION" Then 493: objXL.Activecell.Offset(0, intX + 1).WrapText = False 494: End If 495: Next 496: Else 497: objXL.Activecell.Offset(0, intX + 1).Value = objWMIQualifier.Value 498: If Ucase (objWMIQualifier.Name) = "DESCRIPTION" Then 499: objXL.Activecell.Offset(0, intX + 1).WrapText = False 500: End If 501: End if 502: 503: ' Amended 504: objXL.Activecell.Offset(0, intX + 2).Value = objWMIQualifier.IsAmended 505: ' Local 506: objXL.Activecell.Offset(0, intX + 3).Value = objWMIQualifier.IsLocal 507: ' Overridable 508: objXL.Activecell.Offset(0, intX + 4).Value = objWMIQualifier.IsOverridable 509: ' Propagates to instance 510: objXL.Activecell.Offset(0, intX + 5).Value = objWMIQualifier.PropagatesToInstance 511: ' Propagates to subclass 512: objXL.Activecell.Offset(0, intX + 6).Value = objWMIQualifier.PropagatesToSubclass 513: Next 514: 515: End Function 516: 517: ]]> 518: </script> 519: </job> 520:</package>
Sample 6.14: A generic script for synchronous event notification
1:<?xml version="1.0"?>.: 8:<package> 9: <job> ..: 13: <runtime> ..: 19: </runtime> 20: 21: <script language="VBScript" src="/books/2/679/1/html/2/..\Functions\TinyErrorHandler.vbs" /> 22: <script language="VBScript" src="/books/2/679/1/html/2/..\Functions\DisplayInstanceProperties.vbs" /> 23: 24: <object prog reference="true"/> 25: <object prog /> 26: 27: <script language="VBscript"> 28: <![CDATA[ ..: 32: ' ----------------------------------------------------------------------------------------- 33: Const cComputerName = "LocalHost" 34: Const cWMINameSpace = "root/cimv2" ..: 48: ' -------------------------------------------------------------------------------- 49: ' Parse the command line parameters 50: If WScript.Arguments.Unnamed.Count < 1 Then 51: WScript.Arguments.ShowUsage() 52: WScript.Quit 53: Else 54: strWQLQuery = WScript.Arguments.Unnamed.Item(0) 55: End If 56: 57: strUserID = WScript.Arguments.Named("User") 58: If Len(strUserID) = 0 Then strUserID = "" 59: 60: strPassword = WScript.Arguments.Named("Password") 61: If Len(strPassword) = 0 Then strPassword = "" 62: 63: strComputerName = WScript.Arguments.Named("Machine") 64: If Len(strComputerName) = 0 Then strComputerName = cComputerName 65: 66: strWMINameSpace = WScript.Arguments.Named("NameSpace") 67: If Len(strWMINameSpace) = 0 Then strWMINameSpace = cWMINameSpace 68: strWMINameSpace = UCase (strWMINameSpace) 69: 70: objWMILocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate 71: objWMILocator.Security_.Privileges.Add wbemPrivilegeSecurity 72: Set objWMIServices = objWMILocator.ConnectServer(strComputerName, strWMINameSpace, _ 73: strUserID, strPassword) ..: 76: Set objWMIEvent = objWMIServices.ExecNotificationQuery (strWQLQuery) ..: 79: WScript.Echo "Waiting for events ..." 80: 81: Set objWMIEventInstance = objWMIEvent.NextEvent 82: If Err.Number then 83: WScript.Echo "0x" & Hex(Err.Number) & " - " & Err.Description & " (" & Err.Source & ")" 84: Else 85: WScript.Echo 86: WScript.Echo FormatDateTime(Date, vbLongDate) & " at " & _ 87: FormatDateTime(Time, vbLongTime) & ": '" & _ 88: objWMIEventInstance.Path_.Class & "' has been triggered." 89: DisplayProperties objWMIEventInstance, 2 90: End If ..: 97: WScript.Echo "Finished." 98: 99: ]]> 100: </script> 101: </job> 102:</package>
Sample 6.17: A generic script for asynchronous event notification
1:<?xml version="1.0"?>.: 8:<package> 9: <job> ..: 13: <runtime> ..: 19: </runtime> 20: 21: <script language="VBScript" src="/books/2/679/1/html/2/..\Functions\TinyErrorHandler.vbs" /> 22: <script language="VBScript" src="/books/2/679/1/html/2/..\Functions\DisplayInstanceProperties.vbs" /> 23: <script language="VBScript" src="/books/2/679/1/html/2/..\Functions\PauseScript.vbs" /> 24: 25: <object prog reference="true"/> 26: <object prog /> 27: 28: <script language="VBscript"> 29: <![CDATA[ ..: 33: ' ----------------------------------------------------------------------------------------- 34: Const cComputerName = "LocalHost" 35: Const cWMINameSpace = "root/cimv2" ..: 49: ' -------------------------------------------------------------------------------- 50: ' Parse the command line parameters 51: If WScript.Arguments.Unnamed.Count = 0 Then 52: WScript.Arguments.ShowUsage() 53: WScript.Quit 54: Else 55: strWQLQuery = WScript.Arguments.Unnamed.Item(0) 56: End If 57: 58: strUserID = WScript.Arguments.Named("User") 59: If Len(strUserID) = 0 Then strUserID = "" 60: 61: strPassword = WScript.Arguments.Named("Password") 62: If Len(strPassword) = 0 Then strPassword = "" 63: 64: strComputerName = WScript.Arguments.Named("Machine") 65: If Len(strComputerName) = 0 Then strComputerName = cComputerName 66: 67: strWMINameSpace = WScript.Arguments.Named("NameSpace") 68: If Len(strWMINameSpace) = 0 Then strWMINameSpace = cWMINameSpace 69: strWMINameSpace = UCase (strWMINameSpace) 70: 71: Set objWMISink = WScript.CreateObject ("WbemScripting.SWbemSink", "SINK_") 72: 73: objWMILocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate 74: objWMILocator.Security_.Privileges.AddAsString "SeSecurityPrivilege", True 75: Set objWMIServices = objWMILocator.ConnectServer(strComputerName, strWMINameSpace, _ 76: strUserID, strPassword) ..: 79: objWMIServices.ExecNotificationQueryAsync objWMISink, strWQLQuery,, wbemFlagSendStatus ..: 82: WScript.Echo "Waiting for events..." 83: 84: PauseScript "Click on 'Ok' to terminate the script ..." 85: 86: WScript.Echo vbCRLF & "Cancelling event subscription ..." 87: objWMISink.Cancel ..: 92: WScript.Echo "Finished." 93: 94: ' ----------------------------------------------------------------------------------------- 95: Sub SINK_OnCompleted (iHResult, objWBemErrorObject, objWBemAsyncContext) 96: 97: Wscript.Echo 98: Wscript.Echo "BEGIN - OnCompleted." 99: Wscript.Echo "END - OnCompleted." 100: 101: End Sub 102: 103: ' ----------------------------------------------------------------------------------------- 104: Sub SINK_OnObjectReady (objWbemObject, objWbemAsyncContext) 105: 106: Wscript.Echo 107: Wscript.Echo "BEGIN - OnObjectReady." 108: WScript.Echo FormatDateTime(Date, vbLongDate) & " at " & _ 109: FormatDateTime(Time, vbLongTime) & ": '" & _ 110: objWbemObject.Path_.Class & "' has been triggered." 111: 112: DisplayProperties objWbemObject, 2 113: 114: Wscript.Echo "END - OnObjectReady." 115: 116: End Sub 117: 118: ' ----------------------------------------------------------------------------------------- 119: Sub SINK_OnProgress (iUpperBound, iCurrent, strMessage, objWbemAsyncContext) 120: 121: Wscript.Echo 122: Wscript.Echo "BEGIN - OnProgress." 123: Wscript.Echo "END - OnProgress." 124: 125: End Sub 126: 127: ]]> 128: </script> 129: </job> 130:</package>
Samples 6.18-6.21: Monitoring, managing, and alerting script for the Windows services
1 <?xml version="1.0"?>.: 8:<package> 9: <job> ..: 13: <runtime> ..: 18: </runtime> 19: 20: <script language="VBScript" src="/books/2/679/1/html/2/..\Functions\TinyErrorHandler.vbs" /> 21: <script language="VBScript" src="/books/2/679/1/html/2/..\Functions\PauseScript.vbs" /> 22: <script language="VBScript" src="/books/2/679/1/html/2/..\Functions\LoopSvcStartupRetry.vbs" /> 23: <script language="VBScript" src="/books/2/679/1/html/2/..\Functions\GenerateHTML.vbs" /> 24: <script language="VBScript" src="/books/2/679/1/html/2/..\Functions\SendMessageExtendedFunction.vbs" /> 25: 26: <object prog reference="true"/> 27: <object prog /> 28: <object prog /> 29: 30: <script language="VBscript"> 31: <![CDATA[ ..: 35: ' ----------------------------------------------------------------------------------------- 36: Const cComputerName = "LocalHost" 37: Const cWMINameSpace = "root/cimv2" 38: Const cWMIClass = "Win32_Service" 39: Const cWMIQuery = "Select * from __InstanceModificationEvent Within 10 Where TargetInstance ISA 'Win32_Service'" 40: 41: Const cPauseBetweenRestart = 2 42: Const cRestartLimit = 3 43: 44: Const cTargetRecipient = "Alain.Lissoir@LissWare.NET" 45: Const cSourceRecipient = "WMISystem@LissWare.NET" 46: 47: Const cSMTPServer = "10.10.10.201" 48: Const cSMTPPort = 25 49: Const cSMTPAccountName = "" 50: Const cSMTPSendEmailAddress = "" 51: Const cSMTPAuthenticate = 0' 0=Anonymous, 1=Basic, 2=NTLM 52: Const cSMTPUserName = "" 53: Const cSMTPPassword = "" 54: Const cSMTPSSL = False 55: Const cSMTPSendUsing = 2 ' 1=Pickup, 2=Port, 3=Exchange WebDAV ..: 61: Class clsMonitoredService 62: Public strServiceName 63: Public intServiceRetryCounter 64: End Class ..: 78: ' -------------------------------------------------------------------------------- 79: ' Parse the command line parameters 80: If WScript.Arguments.Unnamed.Count = 0 Then 81: WScript.Arguments.ShowUsage() 82: WScript.Quit 83: Else 84: For intIndice = 0 To WScript.Arguments.Unnamed.Count - 1 85: ReDim Preserve clsService(intIndice) 86: Set clsService(intIndice) = New clsMonitoredService 87: clsService(intIndice).strServiceName = Ucase(WScript.Arguments.Unnamed.Item(intIndice)) 88: clsService(intIndice).intServiceRetryCounter = 0 89: Next 90: End If 91: 92: strUserID = WScript.Arguments.Named("User") 93: If Len(strUserID) = 0 Then strUserID = "" 94: 95: strPassword = WScript.Arguments.Named("strPassword") 96: If Len(strPassword) = 0 Then strPassword = "" 97: 98: strComputerName = WScript.Arguments.Named("Machine") 99: If Len(strComputerName) = 0 Then strComputerName = cComputerName 100: 101: Set objWMISink = WScript.CreateObject ("WbemScripting.SWbemSink", "SINK_") 102: 103: objWMILocator.Security_.AuthenticationLevel = wbemAuthenticationLevelDefault 104: objWMILocator.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate 105: Set objWMIServices = objWMILocator.ConnectServer(strComputerName, cWMINameSpace, _ 106: strUserID, strPassword) ...: 109: For intIndice = 0 To UBound (clsService) 110: 111: Set objWMIInstance = objWMIServices.Get (cWMIClass & "='" & _ 112: clsService(intIndice).strServiceName & "'") 113: 114: boolSvcStatus = LoopServiceStartupRetry (objWMIInstance, intIndice) 115: If boolSvcStatus = False Then 116: WScript.Quit 117: End If 118: 119: If Len(strWMIQuery) = 0 Then 120: strWMIQuery = "TargetInstance.Name='" & clsService(intIndice).strServiceName & "'" 121: Else 122: strWMIQuery = strWMIQuery & " Or " & _ 123: "TargetInstance.Name='" & _ 124: clsService(intIndice).strServiceName & "'" 125: End If 126: 127: WScript.Echo "Adding '" & clsService(intIndice).strServiceName & _ 128: "' to subscription to monitor '" & cWMIClass & "'." & vbCRLF 129: 130: objWMIInstanceSinkContext.Add Cstr(clsService(intIndice).strServiceName), intIndice 131: Next 132: 133: strWMIQuery = cWMIQuery & " And TargetInstance.State='Stopped' And (" & strWMIQuery & ")" 134: 135: objWMIServices.ExecNotificationQueryAsync objWMISink, _ 136: strWMIQuery, _ 137: , _ 138: , _ 139: , _ 140: objWMIInstanceSinkContext ...: 143: WScript.Echo "Waiting for events..." 144: 145: PauseScript "Click on 'Ok' to terminate the script ..." 146: 147: WScript.Echo vbCRLF & "Cancelling event subscription ..." 148: objWMISink.Cancel ...: 153: WScript.Echo "Finished." 154: 155: ' ----------------------------------------------------------------------------------------- 156: Sub SINK_OnCompleted (iHResult, objWBemErrorObject, objWBemAsyncContext) ...: 160: Wscript.Echo 161: Wscript.Echo "BEGIN - OnCompleted." 162: Wscript.Echo "END - OnCompleted." 163: 164: End Sub 165: 166: ' ----------------------------------------------------------------------------------------- 167: Sub SINK_OnObjectReady (objWbemObject, objWbemAsyncContext) ...: 175: Wscript.Echo 176: Wscript.Echo "BEGIN - OnObjectReady." 177: WScript.Echo FormatDateTime(Date, vbLongDate) & " at " & _ 178: FormatDateTime(Time, vbLongTime) & ": '" & _ 179: objWbemObject.Path_.Class & "' has been triggered." 180: 181: Select Case objWbemObject.Path_.Class 182: Case "__InstanceModificationEvent" 183: Set objWMIInstance = objWbemObject 184: Case "__AggregateEvent" 185: Set objWMIInstance = objWbemObject.Representative 186: Case Else 187: Set objWMIInstance = Null 188: End Select 189: 190: If Not IsNull (objWMIInstance) Then 191: boolSvcStatus = LoopServiceStartupRetry (objWMIInstance.TargetInstance, _ 192: objWbemAsyncContext.Item (objWMIInstance.TargetInstance.Name).Value) 193: 194: If boolSvcStatus = False Then 195: If SendMessage (cTargetRecipient, _ 196: cSourceRecipient, _ 197: objWMIInstance.TargetInstance.SystemName & " - " & _ 198: FormatDateTime(Date, vbLongDate) & _ 199: " at " & _ 200: FormatDateTime(Time, vbLongTime), _ 201: GenerateHTML (objWMIInstance.PreviousInstance, _ 202: objWMIInstance.TargetInstance) , _ 203: "") Then 204: WScript.Echo "Failed to send email to '" & cTargetRecipient & "' ..." 205: End If 206: End If 207: End If ...: 211: Wscript.Echo "END - OnObjectReady." 212: 213: End Sub 214: 215: ' ----------------------------------------------------------------------------------------- 216: Sub SINK_OnProgress (iUpperBound, iCurrent, strMessage, objWbemAsyncContext) ...: 220: Wscript.Echo 221: Wscript.Echo "BEGIN - OnProgress." 222: Wscript.Echo "END - OnProgress." 223: 224: End Sub 226: ]]> 227: </script> 228: </job> 229:</package>