Jump to content

Generic failure


Recommended Posts

Hello,

I have a simple script that pulls the name of the logged on user from WMI. When I run it through AutoIT on some computers I'm getting the following error.

Desc = Generic failure

WinDesc = Variable is not of type 'Object'

Source = SWbemServicesEx

What's strange is that if I run the same code in a vbscpt it retuns the value successfully.

AutoIT Code (throws the error)

$strComputer = "."

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")

$colItems = $objWMIService.ExecQuery("Select * From Win32_ComputerSystem","WQL",48)

For $objItem in $colItems

MsgBox (0,"Username", $objItem.UserName)

Next

VBscript (returns the UserName")

On Error Resume Next

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)

For Each objItem in colItems

Wscript.Echo "UserName: " & objItem.UserName

Next

Any idea why vbscript is working, but not AutoIT? I've found some similar posts about this error, but nothing that specifically described the issue I'm seeing. Thanks in advance for the help.

Link to comment
Share on other sites

Why WMI? What's wrong with the AutoIt macro @UserName?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Please have a look at in the Example Scripts section. You select the Namespace and WMI Class and Scriptomatic generates the AutoIt code for you.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

and if you run the script with the $strComputer = "localhost" ?

Edit: "." works fine on my machine, but the only way i can replicate your error is to throw a bogus string for the computer

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

Hi water,

Thanks for the link. That's an awesome tool. Unfortunately, the code it gave me threw the same error.

Hi boththose,

I tired changing it to $strComputer = "localhost" but it still failed with the same error. I also changed it to winmgmts:.rootcimv2 but that also failed.

Link to comment
Share on other sites

The only difference I see is that in VBS the "WQL" is omitted from this statement:

$colItems = $objWMIService.ExecQuery("Select * From Win32_ComputerSystem","WQL",48)
You could try to replace "WQL" in the AutoIt script with the keyword Default.
$colItems = $objWMIService.ExecQuery("Select * From Win32_ComputerSystem",Default,48)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks kylomas. The script I have has run successfully on about 18,000 computers. It's just a handful that have this really strange issue. It's like there's some dependency for AutoIT that doesn't exist, or maybe some dll that is corrupt. I'm really stumped on this one.

Link to comment
Share on other sites

If there is a problem with WMI then I would expect the AutoIt script and the VBS to crash.

Are you sure VBS runs when AutoIt crashes?

BTW: Which version of AutoIt do you run?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

In this case I suggest to add a COM error handler to get more information about the problem.

Add

Global $oMyError = ObjEvent("AutoIt.Error", "MyErrorHandler"
at the top of your script and
Func MyErrorHandler($__oAD_MyError)

Local $bHexNumber = Hex($__oAD_MyError.number, 8)
Local $sError = "COM Error Encountered in " & @ScriptName & @CRLF & _
     "@AutoItVersion = " & @AutoItVersion & @CRLF & _
"@AutoItX64 = " & @AutoItX64 & @CRLF & _
"@Compiled = " & @Compiled & @CRLF & _
"@OSArch = " & @OSArch & @CRLF & _
"@OSVersion = " & @OSVersion & @CRLF & _
"Scriptline = " & $__oAD_MyError.scriptline & @CRLF & _
"NumberHex = " & $bHexNumber & @CRLF & _
"Number = " & $__oAD_MyError.number & @CRLF & _
"WinDescription = " & StringStripWS($__oAD_MyError.WinDescription, 2) & @CRLF & _
"Description = " & StringStripWS($__oAD_MyError.description, 2) & @CRLF & _
"Source = " & $__oAD_MyError.Source & @CRLF & _
"HelpFile = " & $__oAD_MyError.HelpFile & @CRLF & _
"HelpContext = " & $__oAD_MyError.HelpContext & @CRLF & _
"LastDllError = " & $__oAD_MyError.LastDllError
     MsgBox(64, "COM error", $sError)

EndFunc ;==>__AD_ErrorHandler
where you like.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

This is the COM handler I'm using now, but I'll try yours to see if it generates anything more useful. Unfortunately, I had to give the system back to the user so I won't be able to test till tomorrow.

I'll let you know in the morning if I make any progress. Thanks again for all the help so far.

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")


Func MyErrFunc()
Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _
"err.description is: " & @TAB & $oMyError.description & @CRLF & _
"err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
"err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _
"err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
"err.source is: " & @TAB & $oMyError.source & @CRLF & _
"err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $oMyError.helpcontext _
)
Endfunc
Link to comment
Share on other sites

If the messages you posted at the top of this thread is all you get then my COM error handler won't help.

I was hoping that there was a more meaningful error and description before the message you posted.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

I do a lot of WMI scripting in support of a client that uses Microsoft's SCCM client, and see this type of error from time to time. Have you tried doing a rebuild of WMI on the affected machine(s)?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Could you test with the latest Beta version of AutoIt (3.3.9.4)? IIRC the COM error handling has been improved.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 3 weeks later...

Hello. Sorry it's taken me awhile to get back to this. I just wanted to provide an update that I appear to have found the root cause. This issue was only on the Dell M4700 so I decided to start disabling devices to see if there was some kind of driver conflict. As it turns out, as soon as i disabled the video driver, the script worked perfectly. I have no idea why the video driver would prevent AutoIT from enumerating WMI, but it is definitely causing the problem.

The video card is a NVIDIA Quadro K100M.

Driver version is 9.18.13.668

I'm going to upgrade the driver to see if that resolves the issue. Just thought I'd post this as an FYI in case anyone else encounters this issue. 

Link to comment
Share on other sites

  • 3 years later...
On 5/14/2013 at 9:48 PM, bratton said:

Hello. Sorry it's taken me awhile to get back to this. I just wanted to provide an update that I appear to have found the root cause. This issue was only on the Dell M4700 so I decided to start disabling devices to see if there was some kind of driver conflict. As it turns out, as soon as i disabled the video driver, the script worked perfectly. I have no idea why the video driver would prevent AutoIT from enumerating WMI, but it is definitely causing the problem.

 

 

The video card is a NVIDIA Quadro K100M.

Driver version is 9.18.13.668

I'm going to upgrade the driver to see if that resolves the issue. Just thought I'd post this as an FYI in case anyone else encounters this issue. 

Thank you a lot. It works.

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...