Jump to content
Sign in to follow this  
LisHawj

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

 

Share this post


Link to post
Share on other sites

don't append the @CRLF to the $Output  variable


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

@Chimp

Please take me to the range and shoot me, dear lord!  Thank you very much.

Edited by LisHawj
Forgot to thank @Chimp!

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...