Jump to content

sometimes "Variable must be of type "Object"


Recommended Posts

while running this script sometimes I get this error.

I think it has something to do with $cI_CompName = $host. But when I change this the script is not working.

I get the error after "_GUICtrlStatusBar_SetText($StatusBar1, "checking - servicetag " & $cI_CompName)"

the array seems to be oke (with array display)

Func _servicetag()
    Local $BIOS
        _uncheckall()
    _ArrayDisplay($aCompList)
    For $host In $aCompList
        $cI_CompName = $host
        Ping($cI_CompName, 20)
        If @error = 0 Then
            _GUICtrlStatusBar_SetText($StatusBar1, "checking - servicetag " & $cI_CompName)
            _ComputerGetBIOS($BIOS)
            For $i = 1 To $System[0][0] Step 1
                _computertype($cI_CompName)
                If StringLeft($cI_CompName, 4) = "ws-a" Then
                    _ExcelSheetActivate($oExceluser, "admin")
                    _ExcelWriteCell($oExceluser, $BIOS[$i][16], StringTrimLeft($cI_CompName, 4), 3)
                Else
                    _ExcelSheetActivate($oExceluser, "cad")
                    _ExcelWriteCell($oExceluser, $BIOS[$i][16], StringTrimLeft($cI_CompName, 4), 3)
                EndIf
            Next
        Else
            ContinueLoop
        EndIf
    Next
    _saveexcel()
    _statusbaridle()
EndFunc   ;==>_servicetag

the exact error code:

C:\Program Files (x86)\AutoIt3\Include\CompInfo.au3 (1354) : ==> Variable must be of type "Object".:

$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

$colItems = $objWMIService^ ERROR

Link to comment
Share on other sites

Hi Jochem,

The code snipped you provided does not contain the line of code where your script failed.

From the error-message you can see that there is an issue with the object $objWMIService .

If you want us to help you'll need to show us that code snippet. :unsure:

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Link to comment
Share on other sites

I use an UDF that i found here on the forum:

compinfo.au3

but this is the part of that script

;===============================================================================
Func _ComputerGetBIOS(ByRef $aBIOSInfo)
    Local $colItems, $objWMIService, $objItem
    Dim $aBIOSInfo[1][25], $i = 1
    
    $objWMIService = ObjGet("winmgmts:\\" & $cI_Compname & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    
    If IsObj($colItems) Then
        For $objItem In $colItems
            ReDim $aBIOSInfo[UBound($aBIOSInfo) + 1][25]
            $aBIOSInfo[$i][0]  = $objItem.Name
            $aBIOSInfo[$i][1]  = $objItem.Status
            $aBIOSInfo[$i][2]  = $objItem.BiosCharacteristics(0)
            $aBIOSInfo[$i][3]  = $objItem.BIOSVersion(0)
            $aBIOSInfo[$i][4]  = $objItem.Description
            $aBIOSInfo[$i][5]  = $objItem.BuildNumber
            $aBIOSInfo[$i][6]  = $objItem.CodeSet
            $aBIOSInfo[$i][7]  = $objItem.CurrentLanguage
            $aBIOSInfo[$i][8]  = $objItem.IdentificationCode
            $aBIOSInfo[$i][9]  = $objItem.InstallableLanguages
            $aBIOSInfo[$i][10] = $objItem.LanguageEdition
            $aBIOSInfo[$i][11] = $objItem.ListOfLanguages(0)
            $aBIOSInfo[$i][12] = $objItem.Manufacturer
            $aBIOSInfo[$i][13] = $objItem.OtherTargetOS
            $aBIOSInfo[$i][14] = $objItem.PrimaryBIOS
            $aBIOSInfo[$i][15] = __StringToDate($objItem.ReleaseDate)
            $aBIOSInfo[$i][16] = $objItem.SerialNumber
            $aBIOSInfo[$i][17] = $objItem.SMBIOSBIOSVersion
            $aBIOSInfo[$i][18] = $objItem.SMBIOSMajorVersion
            $aBIOSInfo[$i][19] = $objItem.SMBIOSMinorVersion
            $aBIOSInfo[$i][20] = $objItem.SMBIOSPresent
            $aBIOSInfo[$i][21] = $objItem.SoftwareElementID
            $aBIOSInfo[$i][22] = $objItem.SoftwareElementState
            $aBIOSInfo[$i][23] = $objItem.TargetOperatingSystem
            $aBIOSInfo[$i][24] = $objItem.Version
            $i += 1
        Next
        $aBIOSInfo[0][0] = UBound($aBIOSInfo) - 1
        If $aBIOSInfo[0][0] < 1 Then
            SetError(1, 1, 0)
        EndIf
    Else
        SetError(1, 2, 0)
    EndIf
EndFunc ;_ComputerGetBIOS
Edited by Jochem
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...