You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I trying to use your great nodejs module in system monitoring daemon and see very strange behavior. Please see working code sample. When I run it without changes node will exits at 1050-1100 step without any error messages. But this sample have infinite loop.
Changes of timeouts in line 10 are not helps. If I uncomment line 25 with console.log of result object - all begins works ok. If I not touch line 25 and comment line 31 - all works ok too.
What is the reason for this strange behavior?
varwin32ole=require('win32ole');varx=0;varlocator=win32ole.client.Dispatch('WbemScripting.SWbemLocator');varsvr=locator.ConnectServer('.','root/cimv2');// . = self PCfunctiontest(){wmi_query(['DeviceID','FreeSpace','Size'],'Win32_LogicalDisk','Size != Null');x++;console.log(x);setTimeout(test,1);// tested values 1, 10, 50, 100 - all buggy}test();functionwmi_query(fields,from,where){varq='SELECT '+fields.join(',')+' FROM '+from;if(where!==undefined)q+=' WHERE '+where;q=svr.ExecQuery(q);varcount=q.Count;varresult=[];for(variq=0;iq<count;iq++){varitem=q.ItemIndex(iq),obj={};for(vari=0;i<fields.length;i++){obj[fields[i]]=wmi_prop(item,fields[i]);}result.push(obj);//console.log(obj); // 1050-1100 times w/o this}return(result);}functionwmi_prop(obj,propertyname){varproperty=obj[propertyname];// if remove this, works normallyreturnproperty==null ? 'NULL' : property;};
The text was updated successfully, but these errors were encountered:
Also I have a problem for select some fields from WQL. For example, I unable to get CurrentTimeZone value from Win32_OperatingSystem. Node exits with error:
OLE error: [CurrentTimeZone] -2147352570 [CurrentTimeZone] IDispatch::GetIDsOfNames AutoWrap() failed
Similar situation is with SettingID value from Win32_StartupCommand. Both of these values perfectly gets with using cscript.exe + JSscript.
Additional remark. Same code with console.log enabled in line 25 also causes error in 39880 iteration:
OLE error: [Count] -2147352567 [Count] = [1] (It always seems to be appeared at that time you mistake calling 'obj.get { ocv->getProp() }' <-> 'obj.call { ocv->invoke() }'.) IDispatch::Invoke AutoWrap() failed
Hello!
I trying to use your great nodejs module in system monitoring daemon and see very strange behavior. Please see working code sample. When I run it without changes node will exits at 1050-1100 step without any error messages. But this sample have infinite loop.
Changes of timeouts in line 10 are not helps. If I uncomment line 25 with console.log of result object - all begins works ok. If I not touch line 25 and comment line 31 - all works ok too.
What is the reason for this strange behavior?
The text was updated successfully, but these errors were encountered: