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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |