Export (0) Print
Expand All

SWbemObject.GetObjectText_ method

The GetObjectText_ method of the SWbemObject object returns a textual rendering of the object. This object can be used to display an object's contents. Currently, only the MOF syntax is supported as an output format. Notice that the MOF text returned does not contain all the information about the object; the MOF text contains only enough information for the MOF compiler to be able to re-create the original object. For instance, there is no information about the propagated qualifiers or the parent class properties.

For an explanation of this syntax, see Document Conventions for the Scripting API.

Syntax


strMofText = .GetObjectText_( _
  [ ByVal iFlags ] _
)

Parameters

iFlags [in, optional]

Reserved and must be 0 (zero) if specified.

Return value

If successful, this method returns a string that contains the output text.

Error codes

After the completion of the GetObjectText_ method, the Err object may contain one of the error codes in the following table.

Error (Name/Dec/Hex)Meaning
wbemErrFailed
2147749889 (0x80041001)

Unspecified error.

wbemErrInvalidParameter
2147749896 (0x80041008)

Invalid parameter was specified.

wbemErrOutOfMemory
2147749894 (0x80041006)

Not enough memory to complete the operation.

Examples

The following code, taken from the List the Definition of a WMI Class in MOF Format VBScript code sample in the TechNet Gallery, retrieves and displays the textual representation of a WMI class definition in MOF (Managed Object Format) syntax.


strComputer = "." 
strNameSpace = "root\cimv2" 
strClass = "Win32_Service" 
  
Const wbemFlagUseAmendedQualifiers = &h20000 
  
Set objClass = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _  
    strComputer & "\" & strNameSpace) 
 
Set objClass = objWMIService.Get(strClass, wbemFlagUseAmendedQualifiers) 
strMOF = objClass.GetObjectText_ 
  
WScript.Echo strMOF 

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Type library

Wbemdisp.tlb

DLL

Wbemdisp.dll

 

 

Show:
© 2014 Microsoft