-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Description
- Version: 6.11.2
- Platform: Windows 10 v1703 x64
- Subsystem: child_process
I'm trying to use exec to interface with the netsh wlan commands on Windows, and I've been having no trouble up until for some reason I get an exit code of 1 for a very specific command and circumstance. Most commands work fine with no issue, but when trying to call netsh wlan show profiles which lists all wireless network profiles for the system, I get an error ONLY when there are no profiles at all:
Error: Command failed: netsh wlan show profiles
Any profiles exist and the command returns fine. It only takes one, as in the example output below.
Output from netsh wlan show profiles w/o profiles: (error)
Profiles on interface Wi=Fi:
Group policy profiles (read only)
---------------------------------
<None>
User profiles
-------------
<None>
Output from netsh wlan show profiles w/ profiles: (no error)
Profiles on interface Wi=Fi:
Group policy profiles (read only)
---------------------------------
<None>
User profiles
-------------
All User Profile : MyWiFiNetwork
The "error" doesn't seem to prevent the command from executing either. stdout is passed properly and I can proceed if I ignore the error, but then I won't catch any actual errors.
I tried replacing exec with execSync since I couldn't find anything trying to debug the async version and still got the same error. I ended up finding that your binding returns a status of 1 for some reason.
var result = spawn_sync.spawn(options);
The result object returned:
{
output: Array[3] [null, Uint8Array[162], Uint8Array[0] ],
pid: /*pid*/,
signal: null,
status: 1
}
It also has a prototype but this looks like a standard Object prototype.
I have no idea how to try and debug this binding, so that is about as deep of information as I can give on that front, but I have replicated this on multiple machines in isolated code (below).
const execSync = require('child_process').execSync;
try {
let out = execSync('netsh wlan show profiles').toString();
console.log(out);
} catch(err) {
console.error(err);
}
Note: also tried const cp = require('child_process'); followed by cp.execSync() later but this had no effect on behavior.