6

Is there a way to use any ActiveX com components with nodejs?

Actually, I would never need this but I'm running nodejs on Windows and trying to send ping requests without forking new processes (no such module exists for Windows).

As some Activex components exist for sending ping requests with raw sockets, maybe I can use them.


An example of how you can create a COM object from JavaScript is:

var rs = new ActiveXObject("ADODB.Recordset");
Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219
umutm
  • 2,832
  • 4
  • 22
  • 22
  • Not a duplicate, but check out [Can you call COM components from server side javascript?](http://stackoverflow.com/questions/5076228/can-you-call-com-components-from-server-side-javascript). – RB. Jan 16 '13 at 10:22
  • @RB., I had checked it but actually looking for something stable and ready-to-use. Thx much – umutm Jan 16 '13 at 21:46

4 Answers4

7

There is node-win32ole ( npm install win32ole ).

EDIT: win32ole is no longer actively maintained. You could try winax instead.

Steve Glick
  • 698
  • 7
  • 19
idobatter
  • 71
  • 1
  • Seems like your other comment is deleted somehow. I'm using this ICMP component: http://www.activexperts.com/activsocket/objects/icmp/ Can node-win32ole make it work without forking any new processes? – umutm Feb 08 '13 at 13:16
  • @idobetter I can't install win32ole, can you give me some advice? I posted a question about it: http://stackoverflow.com/q/33146316/694360 – mmj Oct 15 '15 at 10:41
  • @mmj see my answer – CarpeDiemKopi Sep 06 '19 at 15:48
1

(updated)

You could try to use node-ffi to bind to Win32 and launch a COM/ActiveX component (CoCreateInstance) or access winsock/icmp directly. See https://github.com/rbranson/node-ffi

Or try to ping via WMI, e.g. "select * from win32_pingstatus where Address='...'". See https://npmjs.org/package/wmi

laktak
  • 57,064
  • 17
  • 134
  • 164
  • Node packages for ping exists but they for new ping.exe processes which I can already do with "exec". I need something that uses "raw sockets" for ICMP. Searched a lot but it doesn't exist for node-win. – umutm Jan 16 '13 at 21:45
  • Both options look awesome. Thanks very much. – umutm Jan 24 '13 at 09:18
  • Tested both: - node-ffi is somehow problematic to install - each wmi query seems to fork a new cscript.exe process which makes no sense Ouch.. – umutm Jan 25 '13 at 13:09
  • Do you know C++? You could write your own extension. A nice small sample for VC++ can be found here: https://github.com/daguej/node-winnetinfo – laktak Jan 28 '13 at 07:40
1

An ICMP ping module for Node.js now exists:

https://npmjs.org/package/net-ping

0

Years later:

node winax

node win32ole no longer works with up to date node.js versions

CarpeDiemKopi
  • 316
  • 3
  • 13