$aevents = $Wmi->ExecQuery(...); print "The error code is ", Win32::OLE->LastError(), "\n";