Jump to content

Recommended Posts

Posted

I want to write a script that does different fuctions dependant on what Mainboard is installed. (install drivers ect.)

I have a script that extracts the WMI Data from the system but I cannot match against it.

I knwo this will be somthing simple but I am new to this and self taught.

dim $bin = _BaseBoard_Properties()
$board = $bin 
InputBox("Base board", "Your Baseboard is: " , $board)
;Exit (0)
if $bin="D945GCZ" Then
    call("test")
Else 
    MsgBox(64,'cannot find board',"Doh")
    EndIf
    
    
Func _BaseBoard_Properties()
    Local $a_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_BaseBoard')
        
        Local $Obj_Item
        For $Obj_Item In $Col_Items
        $a_Text = $Obj_Item.Product & @CRLF
        Next
        
        Return String($a_Text)
    Else
        Return 0
    EndIf
EndFunc

func test()
    MsgBox(64, 'Info', "Found Mainboard")
    EndFunc

I cannot check again't the Mainboard the way I have done it as it has 2 returns at the end. how do I remove these or add them to check against?

I have attached a copy of what my system returns. Can anyone point me in the right direction. I ahve tried stringright command but this does not seem to change it.

Cheers for any help

Robbo

post-21421-1235045981_thumb.jpg

Posted (edited)

I want to write a script that does different fuctions dependant on what Mainboard is installed. (install drivers ect.)

I have a script that extracts the WMI Data from the system but I cannot match against it.

I knwo this will be somthing simple but I am new to this and self taught.

dim $bin = _BaseBoard_Properties()
$board = $bin 
InputBox("Base board", "Your Baseboard is: " , $board)
;Exit (0)
if $bin="D945GCZ" Then
    call("test")
Else 
    MsgBox(64,'cannot find board',"Doh")
    EndIf
    
    
Func _BaseBoard_Properties()
    Local $a_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_BaseBoard')
        
        Local $Obj_Item
        For $Obj_Item In $Col_Items
        $a_Text = $Obj_Item.Product & @CRLF
        Next
        
        Return String($a_Text)
    Else
        Return 0
    EndIf
EndFunc

func test()
    MsgBox(64, 'Info', "Found Mainboard")
    EndFunc

I cannot check again't the Mainboard the way I have done it as it has 2 returns at the end. how do I remove these or add them to check against?

I have attached a copy of what my system returns. Can anyone point me in the right direction. I ahve tried stringright command but this does not seem to change it.

Cheers for any help

Robbo

Try this, you're ending up with a carriage return and a linefeed at the end because you were putting them there in your For...Next loop.

A lot of times with the COM objects, even though you use a For...Next loop to read them, there's only one object anyways...

*Edit - BTW, nice first post with the example and everything, welcome to the forums!

Dim $bin = _BaseBoard_Properties()
$board = $bin
InputBox("Base board", "Your Baseboard is: ", $board)
;Exit (0)
If $bin = "D945GCZ" Then
    Call("test")
Else
    MsgBox(64, 'cannot find board', "Doh")
EndIf


Func _BaseBoard_Properties()
    Local $a_Text = ''
    Dim $Obj_WMIService = ObjGet('winmgmts:\\' & @ComputerName & '\root\cimv2');
    If (IsObj($Obj_WMIService)) And (Not @error) Then
        Dim $Col_Items = $Obj_WMIService.ExecQuery('Select * from Win32_BaseBoard')

        Local $Obj_Item
        For $Obj_Item In $Col_Items
            $a_Text = $Obj_Item.Product
        Next

        Return String($a_Text)
    Else
        Return 0
    EndIf
EndFunc   ;==>_BaseBoard_Properties

Func test()
    MsgBox(64, 'Info', "Found Mainboard")
EndFunc   ;==>test
Edited by exodius
Posted

Try this, you're ending up with a carriage return and a linefeed at the end because you were putting them there in your For...Next loop.

Cheers Exodius. :)

I knew it would be somthing stupid. It was a script that I found from somewhere else I tried to use to attchive what I wanted.

I never noticed I had the @CRLF in there.

Oh and thanks for the compliment on posting. I have used the forum for a while just for looking up stuff. It was my first post though.

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
×
×
  • Create New...