Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

132
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda