Düzenle

Aracılığıyla paylaş


SWbemObjectEx.GetText_ method

The GetText_ method of the SWbemObjectEx object returns an XML representation of an object or instance. The text file is formatted in the XML format specified as shown in WbemObjectTextFormatEnum.

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

Syntax

strObj = .GetText_( _
  ByVal iTextFormat, _
  [ ByVal iFlags ], _
  [ ByVal objWbemNamedValueSet ] _
)

Parameters

iTextFormat [in]

Required. A value from WbemObjectTextFormatEnum that specifies the resulting XML format.

iFlags [in, optional]

Reserved operation flags. The default value is 0 (zero).

objWbemNamedValueSet [in, optional]

An SWbemNamedValueSet object that sets context for the operation. The default is null. For more information about the name/value pairs permitted, see Remarks below.

Return value

This method has no return values.

Error codes

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

wbemErrFailed - 2147749889 (0x80041001)

Unspecified error.

wbemErrNotFound - 2147749890 (0x80041002)

The requested format was not found.

wbemErrInvalidParameter - 2147749896 (0x80041008)

One of the parameters to the call is not correct.

wbemErrCriticalError - 2147749898 (0x8004100A)

An internal, critical, and unexpected error occurred. Report this error to Microsoft Technical Support.

Remarks

When constructing your SWbemNamedValueSet, only the following name/value pairs are permitted.

Name Value
LocalOnly VT_BOOL
If TRUE, only locally defined properties and methods are present in the resulting XML. The default is FALSE.
IncludeQualifiers VT_BOOL
If TRUE, qualifiers of classes, instances, properties, and methods are included in the resulting XML. The default is FALSE.
PathLevel VT-I4
Default is 0 (zero). Possible values are:
  • 0: A <CLASS> or <INSTANCE> element is created depending on whether the object is a class or instance.
  • 1: A <VALUE.NAMEDOBJECT> element is generated.
  • 2: A >VALUE.OBJECTWITHLOCALPATH> element is generated.
  • 3: A >VALUE.OBJECTWITHPATH> element is generated.
ExcludeSystemProperties VT-BOOL
If TRUE, system properties, like __NAMESPACE, are excluded from the output.
IncludeClassOrigin VT_BOOL
If TRUE, the class origin attribute is set on the >PROPERTY> and >METHOD> elements. The default is FALSE.

For more information about creating an SWbemNamedValueSet, see SWbemNamedValueSet.Add.

Examples

The following script shows how to obtain an XML representation of the Win32_Bios class definition. By specifying a particular instance of Win32_Bios, you can obtain that object's data in XML.

' Connect to the default namespace (root\cimv2) with the default
' impersonation level ("impersonate") and obtain a Win32_Bios class
' object.
Set obj = GetObject("winmgmts:win32_bios")

' Use the value for the desired XML CIM DTD format. 
XMLDtd = 1
Text = obj.GetText_(XMLDtd)
wscript.echo Text

Requirements

Requirement Value
Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Header
Wbemdisp.h
Type library
Wbemdisp.tlb
DLL
Wbemdisp.dll
CLSID
CLSID_SWbemObjectEx
IID
IID_ISWbemObjectEx