Page 1 of 1 1
Topic Options
#128637 - 2004-10-29 10:05 AM Get WMI information using INI file
el_coyote Offline
Fresh Scripter

Registered: 2002-05-16
Posts: 14
Hello,

To inventory wmi information, i want to create a kix script that read an ini file to get which WMI information i want to.

---INI FILE---
[WMI]
;WMI_INFO<n>=<wmi_param>,comment,<value1>,<value3>,...,valuen>
WMI_INFO1=WIN32_BIOS,BIOS,Name,Version,SMBIOSBIOSVersion,Version

---KIX_SCRIPT---
$sMyIni="E:\Scripts\SysInvent.ini"

For Each $sSection In Split(ReadProfileString($sMyIni,"",""),Chr(10))
If $sSection = "WMI"
For Each $sEntry In Split(ReadProfileString($sMyIni,$sSection,""),Chr(10))
If $sEntry = "WMI_INFO1"
$aEntry = Split(ReadProfileString($sMyIni,$sSection,$sEntry),",")
$sImax = Ubound($aEntry)
$WMI = $aEntry[0]
$wmiColl = GetObject("WinMgmts:root/cimv2").ExecQuery("Select * FROM $WMI")
For Each $wmiObj In $wmiColl
For $i = 2 to $sImax
$sValueName = $aEntry[1] + "_"
$WMI_RESULT = $wmiObj.$aEntry[$i]
$sValue = $sValueName + $aEntry[$i] + $wmi_result + @CRLF
; $sValue = $sEntry + " : " + $sValue + @CRLF
$ok = WriteFile("E:\Scripts\echo.txt",$sValue)
Next
Next
EndIf
Next
EndIf
Next

The writeline() function is working great.

My problem is this script don't get the wmi value that i want.
I don't know how to script this ...

Thx for help.

Note : i'm french and my english is too bad. If you want, i can post a french version of. Thx

Top
#128638 - 2004-10-29 11:56 AM Re: Get WMI information using INI file
Cybex Offline
Getting the hang of it
*****

Registered: 2004-07-21
Posts: 81
Loc: Brandon, FL.
So it does get info via WMI just not the info you want?

Can you please tell us what information it is that you want WMI to return?
_________________________
Common sense isn't so common.

Top
#128639 - 2004-10-29 12:27 PM Re: Get WMI information using INI file
el_coyote Offline
Fresh Scripter

Registered: 2002-05-16
Posts: 14
my problem is because $WMI_RESULT = $wmiObj.$aEntry[$i] don't return the information.
Normally, if $i = 2, $aEntry[$i) may return Name and $wmiObj.$aEntry[$i] may return the information
I think my code is wrong.

Top
#128640 - 2004-10-29 12:53 PM Re: Get WMI information using INI file
Cybex Offline
Getting the hang of it
*****

Registered: 2004-07-21
Posts: 81
Loc: Brandon, FL.
Have you echoed out this line via "?" or out to a messagebox to see if you code is constructing the request line in the proper format? I have no way at this moment to test it so I figured I would ask.
_________________________
Common sense isn't so common.

Top
#128641 - 2004-10-29 02:14 PM Re: Get WMI information using INI file
el_coyote Offline
Fresh Scripter

Registered: 2002-05-16
Posts: 14
I do ?
$wmiObj.$aEntry[$i] return the value of $aEntry[$i]

For example :
$aEntry[5] while return SMBIOSBIOSVersion, so
$wmiObj.$aEntry[5] while return the number version of my bios but it return SMBIOSBIOSName.
if i try $wmiObj.SMBIOSBIOSName it works.
So it's seems that $wmiObj.$aEntry[$i] is not resolved.

Something wrong in my syntax ?

Top
#128642 - 2004-10-29 02:32 PM Re: Get WMI information using INI file
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Untested :

Code:
$nul = execute("$$WMI_RESULT = $$wmiObj." + $aEntry[$i])

_________________________



Top
#128643 - 2004-10-29 02:55 PM Re: Get WMI information using INI file
el_coyote Offline
Fresh Scripter

Registered: 2002-05-16
Posts: 14
$nul return the name of the wmi properties and it's value.

Ex : SMBIOSBIOSVersionA07

It's not possible to have directly only the value ???

Top
#128644 - 2004-10-29 02:58 PM Re: Get WMI information using INI file
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
No,

$nul is just the bit bucket in this case .. $WMI_RESULT is containing the value
_________________________



Top
#128645 - 2004-10-29 03:23 PM Re: Get WMI information using INI file
el_coyote Offline
Fresh Scripter

Registered: 2002-05-16
Posts: 14
Ok. That's work great now. Thx a lot

DO you think i need to check return code error in my case ?

Top
#128646 - 2004-10-29 03:54 PM Re: Get WMI information using INI file
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
If you rely on return values it's always a good idea to get a decent error checking, so yes...
_________________________



Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.061 seconds in which 0.026 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org