Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

134
Vistas
How to get the WiFI Security Key/Connected WiFi Device using JS

Using the command line netsh wlan show interfaces shows the output below, however I'm trying to make a script where it can pull Profile : 3MobileWiFi-3D71 and only return the result after the : so then I can make a JS Script to then use this data with the following command line Netsh wlan show profile name="${DeviceFromInterfaces}" key=clear which then will only return the following data I need: Key Content : REDACTED

How would I get this data using this module: child_process which uses exec to run most of the stuff aforementioned.

Security settings
-----------------
    Authentication         : WPA2-Personal
    Cipher                 : CCMP
    Authentication         : WPA2-Personal
    Cipher                 : GCMP
    Security key           : Present
    Key Content            : REDACTED

[Interfaces]

There is 1 interface on the system:

    Name                   : WiFi
    Description            : Intel(R) Dual Band Wireless-AC 3160
    GUID                   : REDACTED
    Physical address       : REDACTED
    State                  : connected
    SSID                   : 3MobileWiFi-3D71
    BSSID                  : REDACTED
    Network type           : Infrastructure
    Radio type             : 802.11n
    Authentication         : WPA2-Personal
    Cipher                 : CCMP
    Connection mode        : Profile
    Channel                : 11
    Receive rate (Mbps)    : 65
    Transmit rate (Mbps)   : 65
    Signal                 : 90%
    Profile                : 3MobileWiFi-3D71

    Hosted network status  : Not available
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I'd probably use child_process.spawn or child_process.spawnSync to run the commands, and then use regular expressions to parse the output. Here's what that would look like for the first command:

import {spawn} from 'child_process';

let stdOut = '';

const evaluator = spawn('netsh', ['wlan', 'show', 'interfaces']);

evaluator.stdout.on('data', (data) => {
  stdOut += data.toString();
});

evaluator.on('close', () => {
  const regex = /^profile.*:\s/i;
  const profile = stdOut
    .split('\n')
    .map((ln) => ln.trim())
    .find((ln) => ln.match(regex))
    .replace(regex, '');
  console.log(profile);
});

The callback provided to the close event on evaluator would return the profile name, after which you could take that output and pipe it into your next command — using the same type of logic to parse out the necessary data.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda