Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I write the below code in VFP for knowing UUID 1

Status
Not open for further replies.

Sng1

Programmer
Aug 3, 2021
65
IN
Imports System
Imports System.Management ' requires adding a reference to System.Management
Module Module1

Sub Main()
Try
Dim searcher As New ManagementObjectSearcher( _
"root\CIMV2", _
"SELECT * FROM Win32_ComputerSystemProduct")

For Each queryObj As ManagementObject In searcher.Get()
Console.WriteLine("UUID: {0}", queryObj("UUID"))
Next
Catch err As ManagementException
Console.WriteLine("An error occurred while querying for WMI data: " & err.Message)
End Try
Console.WriteLine("Finished, press ENTER")
Console.ReadLine()
End Sub
End Module
 
Search for CIMV2 in the forum search and you'll find WMI scripting examples.

Here's a very general example to use on many if not all Win32 WMI classes to just list them and their properties:

Code:
LOCAL objWMIService 

objWMIService = Getobject('winmgmts:\\.\root\cimv2')
colItems = objWMIService.ExecQuery('Select * from Win32_ComputerSystemProduct')
For Each objItem In colItems
    FOR EACH loProperty IN objItem.Properties_
        ? loProperty.Name, loProperty.Value
    ENDFOR 
    ? '-----------'
Endfor

Not all Win32_* classes may offer a properties_ collection over which you can iterate and get all property names and values. You could use AMEMBERS() to first check if a member named "Properties_" exists, other members with a trailing underscore in their name point out further collections you can examine further.

Properties can be arrays with many elements, in which case their value might be NULL and not a CSV list of all the array elements. But it's a good starting point for any Win32 WMI class.

SUSPEND the execution within the loop and you may find more details with intellisense on objItem or loProperty and can drill down to more information.

Chriss
 
Yes It worked. Thanks a lot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top