Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!