Hi All

When you connect to the WMI Scripting Library and you execute a semisynchronous query by calling the SWbemServices.ExecQuery method with the IFlags parameters, wbemFlagReturnImmediately and wbemFlagForwardOnly set to 16 and 32, the SWbemLastError method doesn't return any error information when an error occurred within WMI. When you execute a query synchronously and an error occurs, the SWbemLastError object does return error information. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/calling_a_method.asp

Is there a way to work around this or a diffrent way for getting error information in semisynchronous mode?

Many Thanks

use strict; use Win32::OLE('in'); Win32::OLE->Option(Warn => 0); use constant wbemFlagReturnImmediately => 0x10; use constant wbemFlagForwardOnly => 0x20; my ($strComputer, $objSWbemLocator, $objSWbemServices, $colSWbemObject +Set, $objWMILastError); $strComputer = '.'; #SWbemLocator - Connect to server $objSWbemLocator = Win32::OLE->new('WbemScripting.SWbemLocator'); $objSWbemServices = $objSWbemLocator->ConnectServer($strComputer, 'roo +t\\cimv2', 'domain\username', 'password'); if ((0 + Win32::OLE::LastError())) { print '0x' . sprintf("%x", (0 + Win32::OLE::LastError())) . ' - ' . (' +' . Win32::OLE::LastError()), "\n"; } #SWbemServices - ExecQuery $colSWbemObjectSet = $objSWbemServices->ExecQuery('SELECT * FROM Win32 +_Services', 'WQL', wbemFlagReturnImmediately + wbemFlagForwardOnly); if ((0 + Win32::OLE::LastError())) { print '0x' . sprintf("%x", (0 + Win32::OLE::LastError())) . ' - ' +. ('' . Win32::OLE::LastError()), "\n"; $objWMILastError = Win32::OLE->new('WbemScripting.SWbemLastError') +; print 'Operation: ' . $objWMILastError->Operation, "\n"; print 'ParameterInfo: ' . $objWMILastError->ParameterInfo, "\n"; print 'ProviderName: ' . $objWMILastError->ProviderName, "\n"; exit (1); } foreach my $objSWbemObject (in $colSWbemObjectSet) { print 'Name: ' . $objSWbemObject->Name, "\n"; }

In reply to WMI Scripting Library by bzgyj1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.