How to use the wmic.get_list function in wmic

To help you get started, we’ve selected a few wmic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tomas / network / lib / win32.js View on Github external
}

  function set_gateway(obj) {
    exports.gateway_ip_for(obj.name, function(err, res) {
      obj.gateway_ip = res && res != '' ? res : null;
      done();
    })
  }

  function set_netmask(obj) {
    exports.netmask_for(obj.name, function(err, res) {
      obj.netmask = res && res != '' ? res : null;
    })
  }

  wmic.get_list('nic', function(err, nics) {
    if (err) return callback(err);    
    count = nics.length;
    if (count == 0){
      return cb(new Error('No interfaces found.'))
    }
    nics.forEach(function(nic) {
      if (nic.Name && nic.NetConnectionID != '' && nic.MACAddress != '') {

        var obj = {
          name: nic.NetConnectionID,
          // description: nic.Name,
          mac_address: nic.MACAddress,
          ip_address: nic.IPAddress,
          vendor: nic.Manufacturer,
          model: nic.Description,
          type: nic.Name.match(/wi-?fi|wireless/i) ? 'Wireless' : 'Wired'
github sirzdy / share / server / ip-windows.js View on Github external
return new Promise(function (resolve, reject) {
        /* 所有的网络连接,包括有线网络连接,无线网络连接,虚拟网络连接等 */
        Object.keys(ifaces).forEach(function (dev) {
            ifaces[dev].forEach(function (details) {
                if (details.family === 'IPv4') {
                    nets.push(details);
                    ips.push(details.address);
                }
            });
        });
        /* 设备管理器 */
        wmic.get_list('nic', function (err, nics) {
            if (err) return reject(err);
            nics.forEach(function (nic) {
                /* 筛选网卡 */
                if (nic.Name && nic.NetConnectionID != '' && nic.MACAddress != '') {
                    /* 筛选无线网卡 */
                    if (nic.Name.match(/wi-?fi|wireless/i)) {
                        nets.forEach((net) => {
                            if (net.mac.toLowerCase() === nic.MACAddress.toLowerCase()) {
                                wirelessIps.push(net.address);
                            }
                        })
                    }
                }
            })
            resolve({ ips, wirelessIps });
        })

wmic

Wrapper around the WMIC Windows command interface.

MIT
Latest version published 2 years ago

Package Health Score

47 / 100
Full package analysis