[32661] in Perl-Users-Digest
Perl-Users Digest, Issue: 3937 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 30 21:09:24 2013
Date: Tue, 30 Apr 2013 18:09:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 30 Apr 2013 Volume: 11 Number: 3937
Today's topics:
[Win32::OLE] - how to get message like "Invalid Class" <pmantaj@gmail.com>
Re: [Win32::OLE] - how to get message like "Invalid Cla <ben@morrow.me.uk>
Re: [Win32::OLE] - how to get message like "Invalid Cla <pmantaj@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 29 Apr 2013 07:42:57 -0700 (PDT)
From: Przemyslaw <pmantaj@gmail.com>
Subject: [Win32::OLE] - how to get message like "Invalid Class" from wbemtest tool
Message-Id: <fcaff890-63bf-41ef-8866-a4ed6f5358f5@googlegroups.com>
hi all,
I use below code to catch errors:
my $query = "Select * from Win32_Service";
my $items = $wmi->ExecQuery($query, "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly) or print "Cannot execute WMI query \'$query\': ".Win32::OLE->LastError."\n";
but Win32_Service doesn't exist and ExecQuery doesn't return any error. Win32::OLE->LastError return 0.
When I try do it by wbemtest it give me a msg box with error "Invalid class". The class doesn't exist because I don't installed WMI Provider. I want to know if WMI Provider not installed and I could get it if ExecQuery return error but it doesn't.
Is there any way to catch error message if WMI class doesn't exist?
thanks in advance
Przemyslaw
------------------------------
Date: Mon, 29 Apr 2013 22:19:13 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: [Win32::OLE] - how to get message like "Invalid Class" from wbemtest tool
Message-Id: <hn435a-9ql2.ln1@anubis.morrow.me.uk>
Quoth Przemyslaw <pmantaj@gmail.com>:
>
> my $query = "Select * from Win32_Service";
> my $items = $wmi->ExecQuery($query, "WQL", wbemFlagReturnImmediately |
> wbemFlagForwardOnly) or print "Cannot execute WMI query \'$query\':
> ".Win32::OLE->LastError."\n";
>
>
> but Win32_Service doesn't exist and ExecQuery doesn't return any error.
> Win32::OLE->LastError return 0.
>
> When I try do it by wbemtest it give me a msg box with error "Invalid
> class". The class doesn't exist because I don't installed WMI Provider.
> I want to know if WMI Provider not installed and I could get it if
> ExecQuery return error but it doesn't.
> Is there any way to catch error message if WMI class doesn't exist?
I know pretty-much nothing about WMI, but the docmentation says
| If an error occurs when executing this method and you do not use the
| wbemFlagReturnImmediately flag, the Err object is not set until you
| attempt to access the returned object set. However, if you use the
| wbemFlagReturnWhenComplete flag, the Err object is set when the
| ExecQuery method is called.
Ben
------------------------------
Date: Tue, 30 Apr 2013 02:21:09 -0700 (PDT)
From: Przemyslaw <pmantaj@gmail.com>
Subject: Re: [Win32::OLE] - how to get message like "Invalid Class" from wbemtest tool
Message-Id: <fb286a4c-d3aa-4612-a5d6-72772358f43e@googlegroups.com>
W dniu poniedzia=C5=82ek, 29 kwietnia 2013 23:19:13 UTC+2 u=C5=BCytkownik B=
en Morrow napisa=C5=82:
> Quoth Przemyslaw:
>=20
> >=20
>=20
> > my $query =3D "Select * from Win32_Service";
>=20
> > my $items =3D $wmi->ExecQuery($query, "WQL", wbemFlagReturnImmediately =
|
>=20
> > wbemFlagForwardOnly) or print "Cannot execute WMI query \'$query\':
>=20
> > ".Win32::OLE->LastError."\n";
>=20
> >=20
>=20
> >=20
>=20
> > but Win32_Service doesn't exist and ExecQuery doesn't return any error.
>=20
> > Win32::OLE->LastError return 0.
>=20
> >=20
>=20
> > When I try do it by wbemtest it give me a msg box with error "Invalid
>=20
> > class". The class doesn't exist because I don't installed WMI Provider.
>=20
> > I want to know if WMI Provider not installed and I could get it if
>=20
> > ExecQuery return error but it doesn't.
>=20
> > Is there any way to catch error message if WMI class doesn't exist?
>=20
>=20
>=20
> I know pretty-much nothing about WMI, but the docmentation says
>=20
>=20
>=20
> | If an error occurs when executing this method and you do not use the
>=20
> | wbemFlagReturnImmediately flag, the Err object is not set until you
>=20
> | attempt to access the returned object set. However, if you use the
>=20
> | wbemFlagReturnWhenComplete flag, the Err object is set when the
>=20
> | ExecQuery method is called.
>=20
>=20
>=20
> Ben
Ben, thanks for reminder me something like as documentation :)
You are right the problem was in wbemFlagReturnImmediately flag. It doesn't=
generete any error.
I changed of wbemFlagReturnImmediately flag to wbemFlagReturnWhenComplete a=
nd I get an error that I wanted to.=20
For example:
--------------------------------------------
OLE exception from "SWbemServicesEx":
Invalid class
Win32::OLE(0.1709) error 0x80041010
in METHOD/PROPERTYGET "ExecQuery" at test.pm line 332
Cannot execute WMI query 'SELECT * FROM Win32_non_existent_class': OLE exce=
ption from "SWbemServicesEx":
Invalid class
Win32::OLE(0.1709) error 0x80041010
in METHOD/PROPERTYGET "ExecQuery"
--------------------------------------------
Przemyslaw
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 3937
***************************************