Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - simply showing all properties and their values of a wmi class

Reply
 
Old 08-14-2008   #1 (permalink)
James


 
 

simply showing all properties and their values of a wmi class

Hello,
I am using information from wmi and to aid in selecting the class I want to
use I need a way to easily show all the properties and their values of a
specified class... without having to specify each property name.

eg. I do this now:

set oWMI = GetObject("winmgmts:\\.\root\cimv2")
set colItems = oWMI.ExecQuery("SELECT * FROM Win32_ComputerSystem")

For Each oItem in colItems
sMessage = "NumberOfLogicalProcessors: " &
oItem.NumberOfLogicalProcessors &vbcrlf _
& "NumberOfProcessors " & oItem.NumberOfProcessors &vbcrlf _
& "TotalPhysicalMemory: " & oItem.TotalPhysicalMemory
'etc... etc... for each property!
Wscript.Echo sMessage
Next

Wscript.Echo "done"

-------------

I know there must be a way to avoid having to explicitly specify each
property.... how to loop through each object instance, then within each
object instance loop through each property to get at the property names and
values?



My System SpecsSystem Spec
Old 08-14-2008   #2 (permalink)
mr_unreliable


 
 

Re: simply showing all properties and their values of a wmi class

James wrote:
Quote:

> I need a way to easily show all the properties and their values of a
> specified class...
>
hi James,

Take look at the attached hta mini app, and see if it
is what you are looking for.

Note: the attached file has a txt extension, so as to
get around some suspicious av apps, but you can just
remove the txt extension and voila it becomes an hta.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
the answers will be applicable to the questions)



<HTML>
<HEAD>
<HTA:APPLICATION ID="ohta"
APPLICATIONNAME="SaveAsDemo"
BORDER="thin"
BORDERSTYLE="normal"
CAPTION="yes"
ICON=""
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
VERSION="1.0"
WINDOWSTATE="normal">

<TITLE> &nbsp;&nbsp; &lt&lt HTA App to Show Windows Management Instrumentation (WMI) Class Documentation... &gt&gt </TITLE>
<!-- Discription Block --------------------------
'
' Title: Enumerate the WMI Classes and Properties
'
' Description: this demo will produce a "combobox" to show wmi classes.
' The idea is to select a class, and get wmi documentation
' about the methods and properties of that class...
'
' Author: jwarrington*NoSteekinSpam*@worldnet.att.net
' Website: http://home.att.net/~wshvbs/index.htm
'
' Usage: Use at you own risk, tested on win98se...
'
' --- Acknowledgments ----------------------------
' The "original" code showing "how to" do this was posted on the vbScript
' newsgroup, by Dr. Tobias Weltner (author of wsh Scripting Secrets),
' on or about 18 November 2000. The code was copywrited by him.
' This is a translation of Dr. Weltner's code into (American) English,
' plus his code was reworked somewhat and consolidated, to present the
' results in an "hta" format...
' --- end of acknowledgment ----------------------
'
' --- Revision History ---------------------------
' 06Jan02: initial attempt...
' 09Jan02: some further Deutsch-zu-Englisch translations...
' also, change doc window from open.window -to- ShowModalDialog...
' 16Apr02: decided NOT to use document.getElementById("myDiv").innerHTML
' syntax (too many doc.all occurances)...
' 30Aug02: store temp html in shell/environment/process/temp location,
' instead of c:\windows\temp\, to be a little more politically correct...
' 08Apr03: sorted the combo (oops, the wmi classes in the select element)...
' --- end of Revisions ---------------------------
'
' --- end of description block ------------------- -->

<SCRIPT LANGUAGE="JavaScript">
<!--
function jsSortClasses (saOptions) {
// using javascript to sort the wmi classes,
// as vbScript doesn't have this capability (shame on you, Microsoft!)...
// alert("entering: JavaSort");

var jsArray = new VBArray(saOptions).toArray(); // vbScript "safearray" to js array
// alert(jsArray[1].toString()); // verify that the vb array conversion was successful

jsArray.sort(); // sort the array
// alert(jsArray.length); // verify all the elements made it...

// at this point one would expect to go back to vbScript to finish...
// ALAS, that was not to be, there is no way (ugh!) to convert a js array BACK
// to a vbScript array. And so, we will have to finish off the job in js...

// construct the select element header...
var sInsertHTML = "<select id='selClass' onChange='selChangeEvent()'>"
// add the select element items (options) to the element...
for (var i = 0; i < jsArray.length; i++)
sInsertHTML = sInsertHTML + "<option value='" + jsArray[i] + "' >" + jsArray[i];
// finish off the select element, (add end tag)...
sInsertHTML = sInsertHTML + "</select>";

// finally, insert all this stuff into the page...
// var oList = document.getElementById("clsListing")
// oList.innerHTML = sInsertHTML
// alert("done(?)")

// you can't return an array, but you CAN return a string...
return(sInsertHTML);
}
//-->
</SCRIPT>

<SCRIPT LANGUAGE="vbScript">
<!--
'
Option Explicit
'
' resize/reposition opening dialog (during loading)...
window.ResizeTo 600,370
window.MoveTo 100,100


' --- module level variables ---------------------
Dim sSelectedClass ' as string
Dim oSelect ' as object

' --- initialize wmi (method/property) "parameter types" ---
Dim sTypes(103) ' as string
Dim iType ' as integer...
For iType = 0 to 103 ' initialize all...
sTypes(iType) = "???" ' i.e., unknown...
Next ' iType
sTypes(2) = " as Integer" '"SINT16"
sTypes(3) = " as Integer" '"SINT32"
sTypes(4) = " as Integer" '"REAL32"
sTypes(5) = " as Integer" '"REAL64"
sTypes(8) = " as String" '"String"
sTypes(11) = " as Boolean" '"BOOLEAN"
sTypes(13) = " as CIM-Object" '"CIM OBJECT"
sTypes(16) = " as Integer" '"SINT8"
sTypes(17) = " as Integer" '"USINT8"
sTypes(18) = " as Integer" '"USINT16"
sTypes(19) = " as Integer" '"USINT32"
sTypes(20) = " as Integer" '"SINT64"
sTypes(21) = " as Integer" '"USINT64"
sTypes(101) = " as Date/Time" '"Date/Time"
sTypes(103) = " as Unicode" '"Char16"

' --- end of module level variables --------------


Sub GetClassListing()
' msgbox("GetClassListing called")

' instantiate wmi...
Dim oWMI : set oWMI = GetObject("winmgmts:")
'
Dim colSubClasses : Set colSubClasses = oWMI.SubclassesOf ' collection
Dim SubClass ' as object
Dim iSC ' as integer
Dim sClassName ' as string

Dim saClasses() ' as string array
Const cArrayAlloc = 100 ' as integer (allocation block size)
ReDim saClasses(cArrayAlloc)
Dim cClasses : cClasses = 0 ' count
Dim sInsertHTML ' as string

' sInsertHTML = "<select id='selClass' onChange='selChangeEvent()'>"
' enumerate the "classes" of wmi...
For Each SubClass in colSubClasses
' sort out the "win32_" subclasses...
If InStr(LCase(SubClass.Path_),"win32") > 0 then
' found a "win32_" subclass, separate out the path info...
iSC = InStr(SubClass.path_, ":")
sClassName = Mid(SubClass.path_, iSC + 1)
' dbPrint "[enum], " & sClassName
' keep track of how many...
' sInsertHTML = sInsertHTML & "<option value='" & sClassName & "' >" & sClassName
saClasses(cClasses) = sClassName ' enter class names in an array (for sorting)
cClasses = cClasses + 1
if (cClasses Mod cArrayAlloc) = 0 then _
ReDim Preserve saClasses(cClasses + cArrayAlloc) ' allocate another block
' If cClasses => 5 then Exit For ' for debugging only
End If ' test win32_
Next ' subclass

' finished with loop, and end select...
' sInsertHTML = sInsertHTML & "</select>"

' MsgBox(CStr(cClasses))
ReDim Preserve saClasses(cClasses-1) ' trim excess array entries...
' MsgBox(CStr(UBound(saClasses)))

' use java to sort the elements, (and create the select/options html)...
sInsertHTML = jsSortClasses(saClasses)

Dim oList : Set oList = document.all.clsListing
oList.InnerHTML = sInsertHTML

' tell user it's ok to go ahead and make a selection...
document.all("pNotify").InnerTEXT = "finished loading wmi classes, " _
& " go ahead and make a selection... "

' and, show the buttons...
document.all("btnShow").style.visibility = "visible"
document.all("btnClose").style.visibility = "visible"

End Sub


' --- SELECTION CHANGE EVENT ---------------------

Sub selChangeEvent()

Set oSelect = document.all("selClass")
sSelectedClass = oSelect.Value
' msgbox("select change event detected: [" & sSelectedClass) & "]"

document.all("pNotify").InnerTEXT = "Currently selected class is: [" _
& sSelectedClass & "]... "
document.all("pInstruct").InnerTEXT = " Click the 'Show WMI Class Doc'" _
& " button to see the documentation."

End Sub


' --- SHOW CLASS DOCUMENTATION -------------------

Sub ShowClassDocumentation()
Dim sNoClass ' as string
sNoClass = "You have not selected any class to document. " & vbCrLf & vbCrLf _
& "Go back to the ListBox, select a class, then click 'show class methods'... "

if isEmpty(sSelectedClass) then
' an empty variable implies no class selected as yet...
MsgBox sNoClass, vbExclamation, "Internal Error Detected"
Else
' msgbox("Showing Class Documentation for: [" & sSelectedClass & "]")

Dim sFileName
sFileName = CreateDocPage(sSelectedClass)

' use "window.open" if you would like to see multi-windows at once...
' window.open sFileName, Null, _
' "status=no,toolbar=no,menubar=no,location=no "

' use showModalDialog, for one-at-a-time...
' note: "center" doesn't seem to work for me,
' i.e., the form is not centered VERTICALLLY, rather it appears at
' the very top of the screen, so, using Left/Top instead...
Dim sFeatures
sFeatures = "dialogLeft:20px; dialogTop:20px; " _
& "dialogWidth:" & CStr(window.screen.width -30) & "px; " _
& "dialogHeight:" & CStr(window.screen.height -30) & "px; " _
& "center:yes; resizable:yes; scroll:yes; status:no; unadorned:no; help:no; "
showModalDialog sFileName, "", (sFeatures) ' ByVal Features as String

document.all("pNotify").InnerTEXT = _
" ..if you wish to continue, select another class."
document.all("pInstruct").InnerTEXT = " "
End If
End Sub


' --- CREATE DOCUMENTATION PAGE (the HTML file) --

Function CreateDocPage(sClassName)

Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")

' make up an appropriate filename...
' note: oShell.Environment("PROCESS)("TEMP") returns c:\windows\TEMP under win9x...
Dim sTmpDir : sTmpDir = CreateObject("WScript.Shell").Environment("PROCESS")("TEMP") & "\"
Dim sFile : sFile = sTmpDir & sClassName & ".htm"
Dim oFile : Set oFile = fso.CreateTextFile(sFile, true)

' create wmi (specific) class...
Dim oWMICls : Set oWMICls = GetObject("winmgmts:[locale=ms_403]!:" & sClassName)
Dim oClass : Set oClass = oWMICls.SpawnDerivedClass_

' generate an html page with the documentation...
' (and, shove that intrusive and annoying msIE off to the side)...
Dim sCaption : sCaption = "Methods and Properties Documentation for " _
& "Windows Management Instrumentation Class: [" & sClassName & "]" _
& String(20, Chr(160)) ' note: Chr(160) is the 2nd ansi blank

Dim sLt : sLt = Chr(60)
Dim sGt : sGt = Chr(62)

oFile.WriteLine "<html><head><title>" & sCaption & "</title>"
oFile.WriteLine sLt & "SCRIPT LANGUAGE='vbScript'" & sGt
oFile.WriteLine "<!-- "
oFile.WriteLine " window.ResizeTo window.screen.width -30, window.screen.height - 30" ' 700,500 " ' (size of documentation window)
oFile.WriteLine " window.MoveTo 20,20 "
oFile.WriteLine "//-->"
oFile.WriteLine sLt & "/SCRIPT" & sGt
oFile.WriteLine "<style>"
oFile.WriteLine "td {font: 10pt Arial; color: #666600; backgroundcolor: #AAAAAA; }"
oFile.WriteLine "p {font: 10pt Arial; color: #DDDDFF; font-weight:}"
oFile.WriteLine ".mn {font-size: 11pt; color: black; font-weight: bold}"
oFile.WriteLine "</style>"
oFile.WriteLine "</head><body scroll='yes' >"
oFile.WriteLine "<h2>" & sClassName & "</h2><table border=0>"

oFile.WriteLine ShowMethods(oClass) ' generate (html) listing
oFile.WriteLine ShowProperties(oClass)

oFile.WriteLine "</table></body></html>"
oFile.close

CreateDocPage = sFile ' set return (filename)
End Function


' --- SHOW THE METHODS OF THIS CLASS -------------

Function ShowMethods(oClass)
Dim sMList ' as string (listing of methods)...
Dim colMethods, Method ' as collection, as object...
Dim sDesOut ' as string (output description)
Dim sFuncDoc ' as string (function documentation)
Dim inPars, outPars ' as string (in/out Parameters)
Dim colParams, iParam ' as collection, as object (parameter item)
Dim startchar ' as string
Dim iQualifier ' as qualifier item
Dim sParamDesc ' as string (parameter description)
Dim enumVal ' (enumerate supported values)
Dim oRetParam ' as object
Dim sCommandDesc ' as string (command description)
Dim iQual ' as object (qualifier item)
Dim sCheck ' as string
Dim iPos ' as integer
Dim sApi ' as string

' add a header to distinguish methods from properties...
sMList = "<tr><td colspan='2' align='center' style='font-family: ARIAL BLACK; font-size: 12pt; " _
& "font-weight: 600; color: Maroon; background-color: Silver;' >" _
& "---------- CLASS METHODS ---------- </td></tr>"

' --- list the methods of this class ---
Set colMethods = oClass.Methods_

For Each Method in colMethods
sDesOut = ""
sFuncDoc = "<b class=mn>" & Method.Name & "</b>" ' "mn" is method name
' msgbox(Method.Name)

' input parameters for this given method...
Set inPars = Method.InParameters

If Not TypeName(inPars)="Nothing" then ' test valid
Set colParams = inPars.Properties_
startchar = "("

For Each iParam in colParams
sFuncDoc = sFuncDoc & startchar _
& "<b>" & iParam.Name & "</b>" & sTypes(iParam.CIMType) _
& ", "
startchar = ""
' msgbox(iParam.Name)

' get the description(s)...
Set iQualifier = iParam.Qualifiers_
sParamDesc = GetDesc(iQualifier)
' msgbox(sParamDesc)
If sParamDesc <> "" then ' test empty
sDesOut = sDesOut & "<b>" & iParam.Name & "</b>=" & GetDesc(iQualifier) & "<br>"
End If ' test empty

For Each enumVal in iQualifier ' enumerate possible values (if any)...
If Not LCase(enumVal.Name) = "mappingstrings" then
sDesOut = sDesOut & GetQualifier(enumVal)
End If
Next ' enumVal
Next ' iParam

sFuncDoc = Left(sFuncDoc, Len(sFuncDoc)-2) & ")" ' adjust html
end if

' output parameters (if any) for this given method...
Set outPars = Method.OutParameters

If Not TypeName(outPars) = "Nothing" then
Set oRetParam = outPars.Properties_.Item("ReturnValue")
sFuncDoc = "result" & sTypes(oRetParam.CIMType) _
& " = " & sFuncDoc

End If ' test any outPars...

Set iQualifier = Method.Qualifiers_
sCommandDesc = GetDesc(iQualifier)

For Each iQual in iQualifier
If LCase(iQual.Name) = "mappingstrings" then ' if IS mapping string...
sCheck = GetQualifier(iQual)
' msgbox(sCheck)
iPos = InstrRev(sCheck, "=")
' (was: Befehl wird von folgender API-Funktion bereitgestellt: )...
sApi = "This method has been derived from the following API-Function: <br>" _
& Mid(sCheck, iPos+1)
End If ' test mapstr
Next ' iQual

sMList = sMList & "<tr><td valign=top>" & sFuncDoc & "<br>" & sDesOut & "</td>" _
& "<td valign=top>" & Replace(Replace(sCommandDesc, vbCr, ""), vbLf, " ") _
& "<br>" & sApi & "</td></tr>"
Next ' method

ShowMethods = sMList ' set return value (method descriptions as html)
End Function


' --- SHOW PROPERTIES OF THIS CLASS --------------

Function ShowProperties(oClass)
Dim colProps, iProp ' as collection, as object (property item)
Dim sPropName, sPropDesc, sListProp ' as string
Dim colQualifiers, iQualifier ' as collection, as object (qualifier item)

' add a header to distinguish methods from properties...
sListProp = "<tr><td colspan='2' align='center' style='font-family: ARIAL BLACK; font-size: 12pt; " _
& "font-weight: 600; color: Maroon; background-color: Silver;' >" _
& "---------- CLASS PROPERTIES ---------- </td></tr>"

' get the properties of this class...
Set colProps = oClass.properties_

For Each iProp in colProps ' enumerate properties...
sPropName = iProp.Name
Set colQualifiers = iProp.Qualifiers_

For Each iQualifier in colQualifiers
If iQualifier.Name = "Description" then
sPropDesc = iQualifier.Value
End If ' if description
Next ' iqualifier

' set property name into an html table entry...
sListProp = sListProp & "<tr><td valign=top><b class=mn>" & sPropName & "</b></td><td valign=top>"
' replace carriage returns and line feeds with appropriate html...
sListProp = sListProp & Replace(Replace(sPropDesc, vbCr, "<br>"), vbLf, " ") & "</td></tr>"
next

ShowProperties = sListProp ' set return value (property descriptions as html)
End Function


' --- GET QUALIFIER(S) FOR THIS QUALIFIER(?) -----

function GetQualifier(oQual)
Dim sRetVal ' as string (return value)
Dim bIsAnArray ' as boolean
Dim oContext ' as object
Dim iElement ' (array element)

On Error Resume Next

Select Case LCase(oQual.Name) ' by-pass inappropriate types...
Case "description"
Exit Function
Case "id"
Exit Function
Case "cimtype"
Exit Function
Case "in"
Exit Function
End Select

sRetVal = "" ' initialize result...

bIsAnArray = (TypeName(oQual.Value)="Variant()")

If Not bIsAnArray then
sRetVal = sRetVal & oQual.Name & "=" & oQual.Value & "<br>"
' msgbox("[GetQualifier] retval: " & sRetVal)

Else ' IS an array...
sRetVal = sRetVal & oQual.Name & " = Array:" & "<br>"
Set oContext = CreateObject("WBEMScripting.SWBEMNamedValueSet")
oContext.Add "n1", oQual.Value

For iElement = LBound(oContext("n1")) to UBound(oContext("n1"))
If oContext("n1")(iElement) <> "" then ' if not empty...
sRetVal = sRetVal & CStr(iElement) & "=" & oContext("n1")(iElement) & "<br>"
End If ' not empty
Next ' ielement
End If ' not an array

On Error GoTo 0 ' turn off error processing

GetQualifier = sRetVal ' set return result
End Function


' --- GET DESCRIPTION(S) FOR THIS QUALIFIER ------

Function GetDesc(colQualifiers)
Dim iQual ' (qualifier item)
Dim sRetVal ' as string

sRetVal = "" ' initialize...

For Each iQual in colQualifiers
If iQual.Name = "Description" then
On Error Resume Next
sRetVal = iQual.Value

If Err.Number <> 0 then ' test error retrieving this value...
sRetVal = "???"
Err.Clear
End If ' error test
On Error GoTo 0 ' turn off error processing...
End If ' as description
Next ' iqual

GetDesc = sRetVal ' set return value (qualifier descriptions)
End Function

//-->
</SCRIPT>
<!-- this style applicable to the First Dialog/Window shown -->
<style>
h3 {margin-top: 1px; margin-bottom: 2px; padding-top: 0%; padding-bottom: 0%;
font-family: verdana; font-size: 12pt; font-weight: 600; color: Navy; }
body {font-family: verdana; font-size: 10pt; font-weight: 400; color: Navy; }
</style>
</HEAD>

<BODY scroll='no' text='navy' bgcolor='silver' onload='GetClassListing()' >

<h3>Selection of WMI Class to Document... </h3>
<hr size='3px' width='95%' color='Navy'>

<p><u>Explanation of how this dialog works... </u><BR>
You will find a "list box" below, which will (hopefully) contain a listing of the classes currently available in WMI. The idea here is to select one of those classes, and then click the "Show WMI Class Documentation" button. That will then (hopefully) cause new window to pop up, showing the "built-in" Methods and Properties Documentation for that class... </p>

<p>&nbsp; &nbsp; Select WMI Class here: &nbsp;&nbsp;
<span id="clsListing" >
<select id='selClass' onChange='selChangeEvent()'>
<option value='dummy_value' >placeholder_kindly wait for classes to load
</select>
</span>
</p>

<p id='pNotify' style="color: red; " style='font-weight: 600; '>
&nbsp;<BR>Kindly WAIT UNTIL THE WMI CLASSES HAVE LOADED... </p>
<p id='pInstruct' style='color: red; ' >
&nbsp;<BR></p>

<CENTER>
<BUTTON id='btnShow' onclick="ShowClassDocumentation()" style='height: 30px; visibility: hidden; '>
Show WMI Class Documentation</BUTTON>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<BUTTON id='btnClose' onclick="window.close()" style='height: 30px; visibility: hidden; '>Close This Dialog</BUTTON>
</CENTER>

</BODY>
</HTML>
My System SpecsSystem Spec
Old 08-14-2008   #3 (permalink)
urkec


 
 

RE: simply showing all properties and their values of a wmi class

"James" wrote:
Quote:

> Hello,
> I am using information from wmi and to aid in selecting the class I want to
> use I need a way to easily show all the properties and their values of a
> specified class... without having to specify each property name.
>
> eg. I do this now:
>
> set oWMI = GetObject("winmgmts:\\.\root\cimv2")
> set colItems = oWMI.ExecQuery("SELECT * FROM Win32_ComputerSystem")
>
> For Each oItem in colItems
> sMessage = "NumberOfLogicalProcessors: " &
> oItem.NumberOfLogicalProcessors &vbcrlf _
> & "NumberOfProcessors " & oItem.NumberOfProcessors &vbcrlf _
> & "TotalPhysicalMemory: " & oItem.TotalPhysicalMemory
> 'etc... etc... for each property!
> Wscript.Echo sMessage
> Next
>
> Wscript.Echo "done"
>
> -------------
>
> I know there must be a way to avoid having to explicitly specify each
> property.... how to loop through each object instance, then within each
> object instance loop through each property to get at the property names and
> values?
>
>
>
There is a sample function to list all properties of a WMI class instance,
written by Alain Lissoir:

http://www.lissware.net/

You can download it from here, with other samples:

http://www.lissware.net/wmibooks/Vol...ScriptKits.zip

It is in Chapters 4, 5 and 6 folders -> Functions ->
DisplayInstanceProperties.vbs


--
urkec
My System SpecsSystem Spec
Old 08-18-2008   #4 (permalink)
James


 
 

Re: simply showing all properties and their values of a wmi class

thanks, I appreciate it.

"urkec" <urkec@xxxxxx> wrote in message
news:1FCBAA9F-7A1A-4705-B1DD-98E9738C5E5B@xxxxxx
Quote:

> "James" wrote:
>
Quote:

>> Hello,
>> I am using information from wmi and to aid in selecting the class I want
>> to
>> use I need a way to easily show all the properties and their values of a
>> specified class... without having to specify each property name.
>>
>> eg. I do this now:
>>
>> set oWMI = GetObject("winmgmts:\\.\root\cimv2")
>> set colItems = oWMI.ExecQuery("SELECT * FROM Win32_ComputerSystem")
>>
>> For Each oItem in colItems
>> sMessage = "NumberOfLogicalProcessors: " &
>> oItem.NumberOfLogicalProcessors &vbcrlf _
>> & "NumberOfProcessors " & oItem.NumberOfProcessors &vbcrlf _
>> & "TotalPhysicalMemory: " & oItem.TotalPhysicalMemory
>> 'etc... etc... for each property!
>> Wscript.Echo sMessage
>> Next
>>
>> Wscript.Echo "done"
>>
>> -------------
>>
>> I know there must be a way to avoid having to explicitly specify each
>> property.... how to loop through each object instance, then within each
>> object instance loop through each property to get at the property names
>> and
>> values?
>>
>>
>>
>
> There is a sample function to list all properties of a WMI class instance,
> written by Alain Lissoir:
>
> http://www.lissware.net/
>
> You can download it from here, with other samples:
>
> http://www.lissware.net/wmibooks/Vol...ScriptKits.zip
>
> It is in Chapters 4, 5 and 6 folders -> Functions ->
> DisplayInstanceProperties.vbs
>
>
> --
> urkec

My System SpecsSystem Spec
Old 08-18-2008   #5 (permalink)
James


 
 

Re: simply showing all properties and their values of a wmi class

thanks. I had come across that before but didn't try it out... I'll try it
now.

"mr_unreliable" <kindlyReplyToNewsgroup@xxxxxx> wrote in message
news:u3pTKgj$IHA.1016@xxxxxx
Quote:

> James wrote:
Quote:

>> I need a way to easily show all the properties and their values of a
>> specified class...
>>
>
> hi James,
>
> Take look at the attached hta mini app, and see if it
> is what you are looking for.
>
> Note: the attached file has a txt extension, so as to
> get around some suspicious av apps, but you can just
> remove the txt extension and voila it becomes an hta.
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
> the answers will be applicable to the questions)
>
>
>

--------------------------------------------------------------------------------

Quote:

> <HTML>
> <HEAD>
> <HTA:APPLICATION ID="ohta"
> APPLICATIONNAME="SaveAsDemo"
> BORDER="thin"
> BORDERSTYLE="normal"
> CAPTION="yes"
> ICON=""
> MAXIMIZEBUTTON="no"
> MINIMIZEBUTTON="no"
> SHOWINTASKBAR="yes"
> SINGLEINSTANCE="yes"
> SYSMENU="yes"
> VERSION="1.0"
> WINDOWSTATE="normal">
>
> <TITLE> &nbsp;&nbsp; &lt&lt HTA App to Show Windows Management
> Instrumentation (WMI) Class Documentation... &gt&gt </TITLE>
> <!-- Discription Block --------------------------
> '
> ' Title: Enumerate the WMI Classes and Properties
> '
> ' Description: this demo will produce a "combobox" to show wmi classes.
> ' The idea is to select a class, and get wmi documentation
> ' about the methods and properties of that class...
> '
> ' Author: jwarrington*NoSteekinSpam*@worldnet.att.net
> ' Website: http://home.att.net/~wshvbs/index.htm
> '
> ' Usage: Use at you own risk, tested on win98se...
> '
> ' --- Acknowledgments ----------------------------
> ' The "original" code showing "how to" do this was posted on the vbScript
> ' newsgroup, by Dr. Tobias Weltner (author of wsh Scripting Secrets),
> ' on or about 18 November 2000. The code was copywrited by him.
> ' This is a translation of Dr. Weltner's code into (American) English,
> ' plus his code was reworked somewhat and consolidated, to present the
> ' results in an "hta" format...
> ' --- end of acknowledgment ----------------------
> '
> ' --- Revision History ---------------------------
> ' 06Jan02: initial attempt...
> ' 09Jan02: some further Deutsch-zu-Englisch translations...
> ' also, change doc window from open.window -to- ShowModalDialog...
> ' 16Apr02: decided NOT to use document.getElementById("myDiv").innerHTML
> ' syntax (too many doc.all occurances)...
> ' 30Aug02: store temp html in shell/environment/process/temp location,
> ' instead of c:\windows\temp\, to be a little more politically
> correct...
> ' 08Apr03: sorted the combo (oops, the wmi classes in the select
> element)...
> ' --- end of Revisions ---------------------------
> '
> ' --- end of description block ------------------- -->
>
> <SCRIPT LANGUAGE="JavaScript">
> <!--
> function jsSortClasses (saOptions) {
> // using javascript to sort the wmi classes,
> // as vbScript doesn't have this capability (shame on you,
> Microsoft!)...
> // alert("entering: JavaSort");
>
> var jsArray = new VBArray(saOptions).toArray(); // vbScript "safearray"
> to js array
> // alert(jsArray[1].toString()); // verify that the vb array conversion
> was successful
>
> jsArray.sort(); // sort the array
> // alert(jsArray.length); // verify all the elements made it...
>
> // at this point one would expect to go back to vbScript to finish...
> // ALAS, that was not to be, there is no way (ugh!) to convert a js array
> BACK
> // to a vbScript array. And so, we will have to finish off the job in
> js...
>
> // construct the select element header...
> var sInsertHTML = "<select id='selClass' onChange='selChangeEvent()'>"
> // add the select element items (options) to the element...
> for (var i = 0; i < jsArray.length; i++)
> sInsertHTML = sInsertHTML + "<option value='" + jsArray[i] + "' >" +
> jsArray[i];
> // finish off the select element, (add end tag)...
> sInsertHTML = sInsertHTML + "</select>";
>
> // finally, insert all this stuff into the page...
> // var oList = document.getElementById("clsListing")
> // oList.innerHTML = sInsertHTML
> // alert("done(?)")
>
> // you can't return an array, but you CAN return a string...
> return(sInsertHTML);
> }
> //-->
> </SCRIPT>
>
> <SCRIPT LANGUAGE="vbScript">
> <!--
> '
> Option Explicit
> '
> ' resize/reposition opening dialog (during loading)...
> window.ResizeTo 600,370
> window.MoveTo 100,100
>
>
> ' --- module level variables ---------------------
> Dim sSelectedClass ' as string
> Dim oSelect ' as object
>
> ' --- initialize wmi (method/property) "parameter types" ---
> Dim sTypes(103) ' as string
> Dim iType ' as integer...
> For iType = 0 to 103 ' initialize all...
> sTypes(iType) = "???" ' i.e., unknown...
> Next ' iType
> sTypes(2) = " as Integer" '"SINT16"
> sTypes(3) = " as Integer" '"SINT32"
> sTypes(4) = " as Integer" '"REAL32"
> sTypes(5) = " as Integer" '"REAL64"
> sTypes(8) = " as String" '"String"
> sTypes(11) = " as Boolean" '"BOOLEAN"
> sTypes(13) = " as CIM-Object" '"CIM OBJECT"
> sTypes(16) = " as Integer" '"SINT8"
> sTypes(17) = " as Integer" '"USINT8"
> sTypes(18) = " as Integer" '"USINT16"
> sTypes(19) = " as Integer" '"USINT32"
> sTypes(20) = " as Integer" '"SINT64"
> sTypes(21) = " as Integer" '"USINT64"
> sTypes(101) = " as Date/Time" '"Date/Time"
> sTypes(103) = " as Unicode" '"Char16"
>
> ' --- end of module level variables --------------
>
>
> Sub GetClassListing()
> ' msgbox("GetClassListing called")
>
> ' instantiate wmi...
> Dim oWMI : set oWMI = GetObject("winmgmts:")
> '
> Dim colSubClasses : Set colSubClasses = oWMI.SubclassesOf ' collection
> Dim SubClass ' as object
> Dim iSC ' as integer
> Dim sClassName ' as string
>
> Dim saClasses() ' as string array
> Const cArrayAlloc = 100 ' as integer (allocation block size)
> ReDim saClasses(cArrayAlloc)
> Dim cClasses : cClasses = 0 ' count
> Dim sInsertHTML ' as string
>
> ' sInsertHTML = "<select id='selClass' onChange='selChangeEvent()'>"
> ' enumerate the "classes" of wmi...
> For Each SubClass in colSubClasses
> ' sort out the "win32_" subclasses...
> If InStr(LCase(SubClass.Path_),"win32") > 0 then
> ' found a "win32_" subclass, separate out the path info...
> iSC = InStr(SubClass.path_, ":")
> sClassName = Mid(SubClass.path_, iSC + 1)
> ' dbPrint "[enum], " & sClassName
> ' keep track of how many...
> ' sInsertHTML = sInsertHTML & "<option value='" & sClassName & "' >"
> & sClassName
> saClasses(cClasses) = sClassName ' enter class names in an array
> (for sorting)
> cClasses = cClasses + 1
> if (cClasses Mod cArrayAlloc) = 0 then _
> ReDim Preserve saClasses(cClasses + cArrayAlloc) ' allocate
> another block
> ' If cClasses => 5 then Exit For ' for debugging only
> End If ' test win32_
> Next ' subclass
>
> ' finished with loop, and end select...
> ' sInsertHTML = sInsertHTML & "</select>"
>
> ' MsgBox(CStr(cClasses))
> ReDim Preserve saClasses(cClasses-1) ' trim excess array entries...
> ' MsgBox(CStr(UBound(saClasses)))
>
> ' use java to sort the elements, (and create the select/options html)...
> sInsertHTML = jsSortClasses(saClasses)
>
> Dim oList : Set oList = document.all.clsListing
> oList.InnerHTML = sInsertHTML
>
> ' tell user it's ok to go ahead and make a selection...
> document.all("pNotify").InnerTEXT = "finished loading wmi classes, " _
> & " go ahead and make a selection... "
>
> ' and, show the buttons...
> document.all("btnShow").style.visibility = "visible"
> document.all("btnClose").style.visibility = "visible"
>
> End Sub
>
>
> ' --- SELECTION CHANGE EVENT ---------------------
>
> Sub selChangeEvent()
>
> Set oSelect = document.all("selClass")
> sSelectedClass = oSelect.Value
> ' msgbox("select change event detected: [" & sSelectedClass) & "]"
>
> document.all("pNotify").InnerTEXT = "Currently selected class is: [" _
> & sSelectedClass & "]... "
> document.all("pInstruct").InnerTEXT = " Click the 'Show WMI Class Doc'" _
> & " button to see the documentation."
>
> End Sub
>
>
> ' --- SHOW CLASS DOCUMENTATION -------------------
>
> Sub ShowClassDocumentation()
> Dim sNoClass ' as string
> sNoClass = "You have not selected any class to document. " & vbCrLf &
> vbCrLf _
> & "Go back to the ListBox, select a class, then click 'show class
> methods'... "
>
> if isEmpty(sSelectedClass) then
> ' an empty variable implies no class selected as yet...
> MsgBox sNoClass, vbExclamation, "Internal Error Detected"
> Else
> ' msgbox("Showing Class Documentation for: [" & sSelectedClass & "]")
>
> Dim sFileName
> sFileName = CreateDocPage(sSelectedClass)
>
> ' use "window.open" if you would like to see multi-windows at once...
> ' window.open sFileName, Null, _
> ' "status=no,toolbar=no,menubar=no,location=no "
>
> ' use showModalDialog, for one-at-a-time...
> ' note: "center" doesn't seem to work for me,
> ' i.e., the form is not centered VERTICALLLY, rather it appears at
> ' the very top of the screen, so, using Left/Top instead...
> Dim sFeatures
> sFeatures = "dialogLeft:20px; dialogTop:20px; " _
> & "dialogWidth:" & CStr(window.screen.width -30) & "px; " _
> & "dialogHeight:" & CStr(window.screen.height -30) & "px; " _
> & "center:yes; resizable:yes; scroll:yes; status:no; unadorned:no;
> help:no; "
> showModalDialog sFileName, "", (sFeatures) ' ByVal Features as String
>
> document.all("pNotify").InnerTEXT = _
> " ..if you wish to continue, select another class."
> document.all("pInstruct").InnerTEXT = " "
> End If
> End Sub
>
>
> ' --- CREATE DOCUMENTATION PAGE (the HTML file) --
>
> Function CreateDocPage(sClassName)
>
> Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
>
> ' make up an appropriate filename...
> ' note: oShell.Environment("PROCESS)("TEMP") returns c:\windows\TEMP
> under win9x...
> Dim sTmpDir : sTmpDir =
> CreateObject("WScript.Shell").Environment("PROCESS")("TEMP") & "\"
> Dim sFile : sFile = sTmpDir & sClassName & ".htm"
> Dim oFile : Set oFile = fso.CreateTextFile(sFile, true)
>
> ' create wmi (specific) class...
> Dim oWMICls : Set oWMICls = GetObject("winmgmts:[locale=ms_403]!:" &
> sClassName)
> Dim oClass : Set oClass = oWMICls.SpawnDerivedClass_
>
> ' generate an html page with the documentation...
> ' (and, shove that intrusive and annoying msIE off to the side)...
> Dim sCaption : sCaption = "Methods and Properties Documentation for " _
> & "Windows Management Instrumentation Class: [" & sClassName & "]" _
> & String(20, Chr(160)) ' note: Chr(160) is the 2nd ansi blank
>
> Dim sLt : sLt = Chr(60)
> Dim sGt : sGt = Chr(62)
>
> oFile.WriteLine "<html><head><title>" & sCaption & "</title>"
> oFile.WriteLine sLt & "SCRIPT LANGUAGE='vbScript'" & sGt
> oFile.WriteLine "<!-- "
> oFile.WriteLine " window.ResizeTo window.screen.width -30,
> window.screen.height - 30" ' 700,500 " ' (size of documentation window)
> oFile.WriteLine " window.MoveTo 20,20 "
> oFile.WriteLine "//-->"
> oFile.WriteLine sLt & "/SCRIPT" & sGt
> oFile.WriteLine "<style>"
> oFile.WriteLine "td {font: 10pt Arial; color: #666600; backgroundcolor:
> #AAAAAA; }"
> oFile.WriteLine "p {font: 10pt Arial; color: #DDDDFF; font-weight:}"
> oFile.WriteLine ".mn {font-size: 11pt; color: black; font-weight: bold}"
> oFile.WriteLine "</style>"
> oFile.WriteLine "</head><body scroll='yes' >"
> oFile.WriteLine "<h2>" & sClassName & "</h2><table border=0>"
>
> oFile.WriteLine ShowMethods(oClass) ' generate (html) listing
> oFile.WriteLine ShowProperties(oClass)
>
> oFile.WriteLine "</table></body></html>"
> oFile.close
>
> CreateDocPage = sFile ' set return (filename)
> End Function
>
>
> ' --- SHOW THE METHODS OF THIS CLASS -------------
>
> Function ShowMethods(oClass)
> Dim sMList ' as string (listing of methods)...
> Dim colMethods, Method ' as collection, as object...
> Dim sDesOut ' as string (output description)
> Dim sFuncDoc ' as string (function documentation)
> Dim inPars, outPars ' as string (in/out Parameters)
> Dim colParams, iParam ' as collection, as object (parameter item)
> Dim startchar ' as string
> Dim iQualifier ' as qualifier item
> Dim sParamDesc ' as string (parameter description)
> Dim enumVal ' (enumerate supported values)
> Dim oRetParam ' as object
> Dim sCommandDesc ' as string (command description)
> Dim iQual ' as object (qualifier item)
> Dim sCheck ' as string
> Dim iPos ' as integer
> Dim sApi ' as string
>
> ' add a header to distinguish methods from properties...
> sMList = "<tr><td colspan='2' align='center' style='font-family: ARIAL
> BLACK; font-size: 12pt; " _
> & "font-weight: 600; color: Maroon; background-color: Silver;' >"
> _
> & "---------- CLASS METHODS ---------- </td></tr>"
>
> ' --- list the methods of this class ---
> Set colMethods = oClass.Methods_
>
> For Each Method in colMethods
> sDesOut = ""
> sFuncDoc = "<b class=mn>" & Method.Name & "</b>" ' "mn" is method name
> ' msgbox(Method.Name)
>
> ' input parameters for this given method...
> Set inPars = Method.InParameters
>
> If Not TypeName(inPars)="Nothing" then ' test valid
> Set colParams = inPars.Properties_
> startchar = "("
>
> For Each iParam in colParams
> sFuncDoc = sFuncDoc & startchar _
> & "<b>" & iParam.Name & "</b>" & sTypes(iParam.CIMType) _
> & ", "
> startchar = ""
> ' msgbox(iParam.Name)
>
> ' get the description(s)...
> Set iQualifier = iParam.Qualifiers_
> sParamDesc = GetDesc(iQualifier)
> ' msgbox(sParamDesc)
> If sParamDesc <> "" then ' test empty
> sDesOut = sDesOut & "<b>" & iParam.Name & "</b>=" & GetDesc(iQualifier) &
> "<br>"
> End If ' test empty
>
> For Each enumVal in iQualifier ' enumerate possible values (if any)...
> If Not LCase(enumVal.Name) = "mappingstrings" then
> sDesOut = sDesOut & GetQualifier(enumVal)
> End If
> Next ' enumVal
> Next ' iParam
>
> sFuncDoc = Left(sFuncDoc, Len(sFuncDoc)-2) & ")" ' adjust html
> end if
>
> ' output parameters (if any) for this given method...
> Set outPars = Method.OutParameters
>
> If Not TypeName(outPars) = "Nothing" then
> Set oRetParam = outPars.Properties_.Item("ReturnValue")
> sFuncDoc = "result" & sTypes(oRetParam.CIMType) _
> & " = " & sFuncDoc
>
> End If ' test any outPars...
>
> Set iQualifier = Method.Qualifiers_
> sCommandDesc = GetDesc(iQualifier)
>
> For Each iQual in iQualifier
> If LCase(iQual.Name) = "mappingstrings" then ' if IS mapping string...
> sCheck = GetQualifier(iQual)
> ' msgbox(sCheck)
> iPos = InstrRev(sCheck, "=")
> ' (was: Befehl wird von folgender API-Funktion bereitgestellt: )...
> sApi = "This method has been derived from the following API-Function:
> <br>" _
> & Mid(sCheck, iPos+1)
> End If ' test mapstr
> Next ' iQual
>
> sMList = sMList & "<tr><td valign=top>" & sFuncDoc & "<br>" & sDesOut &
> "</td>" _
> & "<td valign=top>" & Replace(Replace(sCommandDesc, vbCr, ""),
> vbLf, " ") _
> & "<br>" & sApi & "</td></tr>"
> Next ' method
>
> ShowMethods = sMList ' set return value (method descriptions as html)
> End Function
>
>
> ' --- SHOW PROPERTIES OF THIS CLASS --------------
>
> Function ShowProperties(oClass)
> Dim colProps, iProp ' as collection, as object (property item)
> Dim sPropName, sPropDesc, sListProp ' as string
> Dim colQualifiers, iQualifier ' as collection, as object (qualifier item)
>
> ' add a header to distinguish methods from properties...
> sListProp = "<tr><td colspan='2' align='center' style='font-family: ARIAL
> BLACK; font-size: 12pt; " _
> & "font-weight: 600; color: Maroon; background-color: Silver;' >"
> _
> & "---------- CLASS PROPERTIES ---------- </td></tr>"
>
> ' get the properties of this class...
> Set colProps = oClass.properties_
>
> For Each iProp in colProps ' enumerate properties...
> sPropName = iProp.Name
> Set colQualifiers = iProp.Qualifiers_
>
> For Each iQualifier in colQualifiers
> If iQualifier.Name = "Description" then
> sPropDesc = iQualifier.Value
> End If ' if description
> Next ' iqualifier
>
> ' set property name into an html table entry...
> sListProp = sListProp & "<tr><td valign=top><b class=mn>" & sPropName &
> "</b></td><td valign=top>"
> ' replace carriage returns and line feeds with appropriate html...
> sListProp = sListProp & Replace(Replace(sPropDesc, vbCr, "<br>"),
> vbLf, " ") & "</td></tr>"
> next
>
> ShowProperties = sListProp ' set return value (property descriptions as
> html)
> End Function
>
>
> ' --- GET QUALIFIER(S) FOR THIS QUALIFIER(?) -----
>
> function GetQualifier(oQual)
> Dim sRetVal ' as string (return value)
> Dim bIsAnArray ' as boolean
> Dim oContext ' as object
> Dim iElement ' (array element)
>
> On Error Resume Next
>
> Select Case LCase(oQual.Name) ' by-pass inappropriate types...
> Case "description"
> Exit Function
> Case "id"
> Exit Function
> Case "cimtype"
> Exit Function
> Case "in"
> Exit Function
> End Select
>
> sRetVal = "" ' initialize result...
>
> bIsAnArray = (TypeName(oQual.Value)="Variant()")
>
> If Not bIsAnArray then
> sRetVal = sRetVal & oQual.Name & "=" & oQual.Value & "<br>"
> ' msgbox("[GetQualifier] retval: " & sRetVal)
>
> Else ' IS an array...
> sRetVal = sRetVal & oQual.Name & " = Array:" & "<br>"
> Set oContext = CreateObject("WBEMScripting.SWBEMNamedValueSet")
> oContext.Add "n1", oQual.Value
>
> For iElement = LBound(oContext("n1")) to UBound(oContext("n1"))
> If oContext("n1")(iElement) <> "" then ' if not empty...
> sRetVal = sRetVal & CStr(iElement) & "=" & oContext("n1")(iElement) &
> "<br>"
> End If ' not empty
> Next ' ielement
> End If ' not an array
>
> On Error GoTo 0 ' turn off error processing
>
> GetQualifier = sRetVal ' set return result
> End Function
>
>
> ' --- GET DESCRIPTION(S) FOR THIS QUALIFIER ------
>
> Function GetDesc(colQualifiers)
> Dim iQual ' (qualifier item)
> Dim sRetVal ' as string
>
> sRetVal = "" ' initialize...
>
> For Each iQual in colQualifiers
> If iQual.Name = "Description" then
> On Error Resume Next
> sRetVal = iQual.Value
>
> If Err.Number <> 0 then ' test error retrieving this value...
> sRetVal = "???"
> Err.Clear
> End If ' error test
> On Error GoTo 0 ' turn off error processing...
> End If ' as description
> Next ' iqual
>
> GetDesc = sRetVal ' set return value (qualifier descriptions)
> End Function
>
> //-->
> </SCRIPT>
> <!-- this style applicable to the First Dialog/Window shown -->
> <style>
> h3 {margin-top: 1px; margin-bottom: 2px; padding-top: 0%; padding-bottom:
> 0%;
> font-family: verdana; font-size: 12pt; font-weight: 600; color:
> Navy; }
> body {font-family: verdana; font-size: 10pt; font-weight: 400; color:
> Navy; }
> </style>
> </HEAD>
>
> <BODY scroll='no' text='navy' bgcolor='silver' onload='GetClassListing()'
Quote:

> >
>
> <h3>Selection of WMI Class to Document... </h3>
> <hr size='3px' width='95%' color='Navy'>
>
> <p><u>Explanation of how this dialog works... </u><BR>
> You will find a "list box" below, which will (hopefully) contain a listing
> of the classes currently available in WMI. The idea here is to select one
> of those classes, and then click the "Show WMI Class Documentation"
> button. That will then (hopefully) cause new window to pop up, showing
> the "built-in" Methods and Properties Documentation for that class... </p>
>
> <p>&nbsp; &nbsp; Select WMI Class here: &nbsp;&nbsp;
> <span id="clsListing" >
> <select id='selClass' onChange='selChangeEvent()'>
> <option value='dummy_value' >placeholder_kindly wait for classes to
> load
> </select>
> </span>
> </p>
>
> <p id='pNotify' style="color: red; " style='font-weight: 600; '>
> &nbsp;<BR>Kindly WAIT UNTIL THE WMI CLASSES HAVE LOADED... </p>
> <p id='pInstruct' style='color: red; ' >
> &nbsp;<BR></p>
>
> <CENTER>
> <BUTTON id='btnShow' onclick="ShowClassDocumentation()" style='height:
> 30px; visibility: hidden; '>
> Show WMI Class Documentation</BUTTON>
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
> <BUTTON id='btnClose' onclick="window.close()" style='height: 30px;
> visibility: hidden; '>Close This Dialog</BUTTON>
> </CENTER>
>
> </BODY>
> </HTML>

My System SpecsSystem Spec
Old 08-18-2008   #6 (permalink)
Paul Randall


 
 

Re: simply showing all properties and their values of a wmi class


"James" <noone@xxxxxx> wrote in message
news:eNmMZWj$IHA.3756@xxxxxx
Quote:

> Hello,
> I am using information from wmi and to aid in selecting the class I want
> to use I need a way to easily show all the properties and their values of
> a specified class... without having to specify each property name.
>
> eg. I do this now:
>
> set oWMI = GetObject("winmgmts:\\.\root\cimv2")
> set colItems = oWMI.ExecQuery("SELECT * FROM Win32_ComputerSystem")
>
> For Each oItem in colItems
> sMessage = "NumberOfLogicalProcessors: " &
> oItem.NumberOfLogicalProcessors &vbcrlf _
> & "NumberOfProcessors " & oItem.NumberOfProcessors &vbcrlf _
> & "TotalPhysicalMemory: " & oItem.TotalPhysicalMemory
> 'etc... etc... for each property!
> Wscript.Echo sMessage
> Next
>
> Wscript.Echo "done"
>
> -------------
>
> I know there must be a way to avoid having to explicitly specify each
> property.... how to loop through each object instance, then within each
> object instance loop through each property to get at the property names
> and values?
You might want to build a .HTA for this. You might use Microsoft's free
downloads for HTA HelpOMatic and (WMI) ScriptOMatic to help build your HTA
and borrow parts of their code for building and executing snippets of
VBScript, JScript, Perl, and Python code to access the WMI info of interest.
ScriptOMatic builds code to display the values. You should be able to
figure out how to automatically execute the code and extract and display the
values you are interested in. This will slow down the script somewhat, but
it will probably be usable.

-Paul Randall


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
When a class is both an inherited class of another, and alsoimplements an interface method .NET General
Simply problem but need some help. Browsers & Mail
HELP-How do I simply add a contact? Live Messenger
c# class configuration properties. .NET General
function: Showing valid parameter values for a set PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46