node-wifi
node-wifi copied to clipboard
Windows: Connect to Wifi interface with spacing name failed
If the wifi interface name contains spacing (e.g. 'Wi-Fi 2'), the connect() returns stdout with 'One or more parameters for the command are not correct or missing.'
Expected Behavior
The connect() should execute system command as "netsh wlan connect ssid="
Current Behavior
connect() returns with following error: Say ssid="my_wifi", interface="Wi-Fi 2"
`Error: Command failed: netsh wlan connect ssid="my_wifi" name="my_wifi" interface="Wi-Fi 2"
at ChildProcess.exithandler (child_process.js:303:12)
at ChildProcess.emit (events.js:310:20)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {
killed: false,
code: 1,
signal: null,
cmd: 'netsh wlan connect ssid="my_wifi" name="my_wifi" interface="Wi-Fi 2"',
stdout: 'One or more parameters for the command are not correct or missing.\r\n' +
'\r\n' +
'Usage: connect [name=]
Affected features
- [Y] node API
- [ ] cli
Possible Solution
I managed to resolve manually in 'windows-connect.js':
- In
connectToWifi()
, changedvar cmd = 'cmd
tovar cmd = 'netsh'
- In
execCommand()
, addedshell: true
in theexecFile()
call
Steps to Reproduce (for bugs)
- Prepare Windows environment with multiple wifi adaptors and make sure one has the wifi interface name with 'spacing', e.g. 'Wi-Fi 2'
- Init with the interface.
wifi.init({ iface: 'Wi-Fi 2'})
- Run connect.
wifi.connect({ ssid: "my_wifi", password: "my_passwd"}, cb)
- Fails with stdout err
Context
Your Environment
- OS: Windows10
- node-wifi version: 2.0.12
- wifi card: Atheros AR9271 Wireless Network Adapter