Sign in to follow this  
Followers 0
redfive19

BIOS Check

7 posts in this topic

Hello all,

I am checking the BIOS version and MODEL # in PE. The functions to do this work perfect. If I pipe it out to a text file, i reads just like the INI listed below. When I do an INI read, it returns the 'default' key. It seems that IniRead doesn't pick up the model key when I read it using variables. Can anyone tell me what I am doing wrong? For some reasons, the strings don't match up. Thanks ahead of time!!

- redfive

BIOSUpdate.ini

[MODEL]
LatitudeD620=A08

BIOSUpdate.au3 code

$model = _GetPCModel('.')
$model = StringReplace($model, ' ', '')
$bios = _GetBIOSVer('.')

$biosread = IniRead(@ScriptDir & '\BIOSUpdate.ini', 'MODEL', $model, 'default')

If $biosread <> $bios Then
    MsgBox(0, '', 'needs to be updated')
Else
    MsgBox(0, '', 'doesnt need to be updated')
EndIf


Func _GetPCModel($strComputer)
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
;$strComputer = "sys0404"
    $Output=""
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) then
        For $objItem In $colItems
        $Output = $objItem.Name & @CRLF
   ;if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
        Return($Output)
        $Output=""
        Next
    Else
;~       Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ComputerSystemProduct" )
    Endif
EndFunc

Func _GetBIOSVer($strComputer)
    $wbemFlagReturnImmediately = 0x10
    $wbemFlagForwardOnly = 0x20
    $colItems = ""
;$strComputer = "sys0404"
    $Output=""
    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

    If IsObj($colItems) then
        For $objItem In $colItems
        $Output = $objItem.SMBIOSBIOSVERSION & @CRLF
   ;if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
        Return($Output)
        $Output=""
        Next
    Else
;~       Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_ComputerSystemProduct" )
    Endif
EndFunc

Share this post


Link to post
Share on other sites



yes actually to write the INI file, I did a FileWrite with the $model to make the INI

Share this post


Link to post
Share on other sites

This shows up the problem:

$model = _GetPCModel('.')
ConsoleWrite("Debug: $model = '" & $model & "'" & @LF)
$model = StringReplace($model, ' ', '')
ConsoleWrite("Debug: $model = '" & $model & "'" & @LF)
$bios = _GetBIOSVer('.')
ConsoleWrite("Debug: $bios = '" & $bios & "'" & @LF)

$biosread = IniRead(@ScriptDir & '\BIOSUpdate.ini', 'MODEL', $model, 'default')
ConsoleWrite("Debug: $biosread = '" & $biosread & "'" & @LF)oÝ÷ Ù.­û§rبƫy§]xìm­ ,[ajܨ¹ªÞl¶¸©¦)à¡÷åj׫jëh×6$Output = $objItem.Name & @CRLF

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I was just going to post that same answer. I noticed there was whitespace or something in the model name because it worked when I hardcoded the model in for $model.

Share this post


Link to post
Share on other sites

I feel dumb.....I got those functions off of someone's post and it was probably there for their purpose. :)

BUT AGAIN, thank you!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0