Jump to content

Help with comparing two strings/values.


Recommended Posts

I am writing a script to identify laptop models and compare it with a reference variable.  If the computer model string match, then the script execute other functions.  I have written the following, but the script reports the value/strings do not match.  Am I overlooking something simple here?

Global $e5490 = "Latitude 5490"
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _
        $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
    For $objItem In $colItems
        $Output = $objItem.Model & @CRLF
    Next
Else
    Sleep(10)
EndIf

Msgbox(0,"",$Output)
$i = StringCompare($Output,$e5490)

If $i = 0 Then
    MsgBox(0,"","Yes! A match!")
Else
    MsgBox(0,"","No! Not a match!")
EndIf

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...