WMI_GetData

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Modules > WMI >

WMI_GetData

 

Description

 

General function to return all possible info about a WMI class name for a given computer.

 

Syntax

 

sBuffer = WMI_GetData(sComputername, sNameSpace, sUserName, sPassword, sClassName [, sWhere [, sFields]])

 

Returns

 

String

sBuffer is a sequence of $CRLF separated strings containing info name and value.

To be able to parse returned information, see below example.

 

Parameters

 

Name

Type

Optional

Meaning

sKey

String

No

Computer name

sNameSpace

String

No

name of the namespace that provides support for the needed class

sUserName

String

No

in case of remote login. Better to specify it in the form "domain\user"

sPassword

String

No

if sUserName is specified, enter here user password

sClassName

String

No

Class name. See WMI class names list for the list of available classes

sWhere

String

Yes

WHERE clause. This field is used to Indicate some selection restrictions.

Example:

"DeviceID = 'C:'"

 

sFields

String

Yes

String containing the names of the information to be returned. More info names can be indicated separated by a comma (,).

Example:

"Name, Size"

 

 

Remarks

 

Not all classes can be available.

 

Restrictions

 

See also

 

Examples

 

Uses "WMI""OS"

Uses "CONSOLE"

 

Dim vData()       As String

Dim nItems        As Long

Dim Counter       As Long

Dim ComputerName  As String = OS_GetComputerName

Dim sBuffer       As String

 

'--- Ask data to WMI system

sBuffer = WMI_GetData(ComputerName, """""""CIM_LogicalDisk""DeviceID = 'C:'" )

 

 

'--- Other possible examples

'sBuffer = WMI_GetData(ComputerName, "", "", "", "Win32_StartupCommand", "", "Command" )

'sBuffer = WMI_GetData(ComputerName, "", "", "", "CIM_LogicalDisk", "DeviceID = 'C:'", "Name, Size" )

'sBuffer = WMI_GetData(ComputerName, "", "", "", "CIM_Battery")

'sBuffer = WMI_GetData(ComputerName, "", "", "", "CIM_LogicalDisk")

'sBuffer = WMI_GetData(ComputerName, "", "", "", "CIM_NetworkAdapter")

'sBuffer = WMI_GetData(ComputerName, "", "", "", "Win32_StartupCommand")

'sBuffer = WMI_GetData(ComputerName, "", "", "", "Win32_Processor")

'sBuffer = WMI_GetData(ComputerName, "", "", "", "CIM_DiskDrive")

'sBuffer = WMI_GetData(ComputerName, "", "", "", "Win32_BIOS")

'sBuffer = WMI_GetData(ComputerName, "", "", "", "Win32_CodecFile")

'sBuffer = WMI_GetData(ComputerName, "", "", "", "CIM_LogicalDisk")

                                                                    

' -- Parse returned data into single lines

nItems = Parse( sBuffer, vData(), $CRLF

 

'---Print lines                           

For Counter = 1 To nItems                 

  Printl vData(Counter)        

Next                                     

 

'---Finished                              

Printl "-----------------------------------------------------"

Printl "Number of lines: " & nItems                           

Printl "---------------------------Press a key to finish-----"   

 

WaitKey