Sign in to follow this  
Followers 0
Jochem

Missing right bracket ')' in expression.

9 posts in this topic

#1 ·  Posted (edited)

I can`t figure out what is wrong with this script

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

$colItems = ^ ERROR

Func _ComputerGetSoftware(ByRef $aSoftwareInfo)
Local $colItems, $objWMIService, $objItem
Dim $aSoftwareInfo[1][13], $i = 1
$objWMIService = ObjGet("winmgmts:\\" & $cI_Compname & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Product", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objItem In $colItems
ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][13]
$aSoftwareInfo[$i][0] = $objItem.Name
$aSoftwareInfo[$i][1] = $objItem.Caption
$aSoftwareInfo[$i][2] = $objItem.Description
$aSoftwareInfo[$i][3] = $objItem.IdentifyingNumber
$aSoftwareInfo[$i][4] = $objItem.InstallDate
$aSoftwareInfo[$i][5] =  __StringToDate($objItem.InstallDate2)
$aSoftwareInfo[$i][6] = $objItem.InstallLocation
$aSoftwareInfo[$i][7] = $objItem.InstallState
$aSoftwareInfo[$i][8] = $objItem.Name
$aSoftwareInfo[$i][9] = $objItem.PackageCache
$aSoftwareInfo[$i][10] = $objItem.SKUNumber
$aSoftwareInfo[$i][11] = $objItem.Vendor
$aSoftwareInfo[$i][12] = $objItem.Version
$i += 1
Next
$aSoftwareInfo[0][0] = UBound($aSoftwareInfo) - 1
If $aSoftwareInfo[0][0] < 1 Then
SetError(1, 1, 0)
EndIf
Else
SetError(1, 2, 0)
EndIf
EndFunc

does anyone has an idea?

Edited by Jochem

Share this post


Link to post
Share on other sites



You're missing stuff.

AutoIt3 Syntax Checker v1.54.8 Copyright © Tylo 2007

C:\Documents and Settings\rcmaeh01\Desktop\test.au3(4,54) : WARNING: $cI_Compname: possibly used before declaration.

$objWMIService = ObjGet("winmgmts:\\" & $cI_Compname &

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\rcmaeh01\Desktop\test.au3(5,103) : WARNING: $wbemFlagReturnImmediately: possibly used before declaration.

$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Product", "WQL", $wbemFlagReturnImmediately +

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\rcmaeh01\Desktop\test.au3(5,125) : WARNING: $wbemFlagForwardOnly: possibly used before declaration.

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

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\rcmaeh01\Desktop\test.au3(4,54) : ERROR: $cI_Compname: undeclared global variable.

$objWMIService = ObjGet("winmgmts:\\" & $cI_Compname &

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\rcmaeh01\Desktop\test.au3(14,62) : ERROR: __StringToDate(): undefined function.

$aSoftwareInfo[$i][5] = __StringToDate($objItem.InstallDate2)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\rcmaeh01\Desktop\test.au3 - 2 error(s), 3 warning(s)

>Exit code: 2 Time: 0.370


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

If Not(IsDeclared("$cI_CompName")) Then
 
Global $cI_CompName = @ComputerName
EndIf
Global $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20

and this is the string to date function that i Use:

Func __StringToDate($dtmDate)
 
Return (StringMid($dtmDate, 5, 2) & "/" & _
StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _
& " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2))
EndFunc ;__StringToDate Function created by SvenP Modified by JSThePatriot
Edited by Jochem

Share this post


Link to post
Share on other sites

AutoIt3 Syntax Checker v1.54.8 Copyright © Tylo 2007

C:\Documents and Settings\rcmaeh01\Desktop\test.au3 - 0 error(s), 0 warning(s)

>Exit code: 0 Time: 0.251

I'm getting no errors.


My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF, WindowEx UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites

neither do I On my computer but I'll get it on 1 of the 100 computer here.

Share this post


Link to post
Share on other sites

On some computers WMI doesnt work or is damaged. I tried everything but cant get WMI to work on all PC's.

Share this post


Link to post
Share on other sites

but for those errors I have an error handler included:

$oErrors = ObjEvent("AutoIt.Error", "Error_Handle")
 
 
Func Error_Handle()
MsgBox(0, "Debug Information", "An error has occured!" & @CRLF & @CRLF & _
"err.description is: " & @TAB & $oErrors.description & @CRLF & _
"err.windescription:" & @TAB & $oErrors.windescription & @CRLF & _
"err.number is: " & @TAB & Hex($oErrors.number, 8) & @CRLF & _
"err.lastdllerror is: " & @TAB & $oErrors.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oErrors.scriptline & @CRLF & _
"err.source is: " & @TAB & $oErrors.source & @CRLF & _
"err.helpfile is: " & @TAB & $oErrors.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $oErrors.helpcontext & @CRLF & @CRLF & @CRLF, 5)
Return SetError($oErrors.number)
EndFunc   ;==>Error_Handle

isn't this enough. Do I need another error handle

Share this post


Link to post
Share on other sites

After this line :$objWMIService = ObjGet("winmgmts:\\" & $cI_Compname & "\root\CIMV2")Put an IsObj($objWMIService) check . IF WMI is damaged - it wont be an object.

Share this post


Link to post
Share on other sites

I have tested this too, but today I got the error again.....

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  
Followers 0