Jump to content
Sign in to follow this  

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
    For $host In $aCompList
        $cI_CompName = $host
        Ping($cI_CompName, 20)
        If @error = 0 Then
            _GUICtrlStatusBar_SetText($StatusBar1, "checking - servicetag " & $cI_CompName)
            For $i = 1 To $System[0][0] Step 1
                If StringLeft($cI_CompName, 4) = "ws-a" Then
                    _ExcelSheetActivate($oExceluser, "admin")
                    _ExcelWriteCell($oExceluser, $BIOS[$i][16], StringTrimLeft($cI_CompName, 4), 3)
                    _ExcelSheetActivate($oExceluser, "cad")
                    _ExcelWriteCell($oExceluser, $BIOS[$i][16], StringTrimLeft($cI_CompName, 4), 3)
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

Share this post

Link to post
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]

Share this post

Link to post
Share on other sites

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


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
        $aBIOSInfo[0][0] = UBound($aBIOSInfo) - 1
        If $aBIOSInfo[0][0] < 1 Then
            SetError(1, 1, 0)
        SetError(1, 2, 0)
EndFunc ;_ComputerGetBIOS
Edited by Jochem

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.