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="" name="" interface="" and expects no error.
Current Behavior
connect() returns with following error:
Say ssid="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=] [[ssid=]] [[interface=]] \r\n' +
'\r\n' +
'Parameters:\r\n' +
'\r\n' +
' Tag Value\r\n' +
' ssid - SSID of the wireless network.\r\n' +
' name - Name of the profile to be used in connection attempt.\r\n' +
' interface - Name of the interface from which connection is attempted.\r\n' +
'\r\n' +
'Remarks:\r\n' +
'\r\n' +
' Connect to the wireless network given by ssid using the specified \r\n' +
' profile. Connection is attempted from the specified interface unless \r\n' +
' there is only one available interface on the system, in which case, \r\n' +
' the interface parameter can be omitted.\r\n' +
'\r\n' +
' Parameter profile name is required but ssid is optional. If only one\r\n' +
' SSID exists in the profile, then this SSID is used to connect. If there\r\n' +
' are multiple SSIDs in the profile, then parameter ssid is required.\r\n' +
'\r\n' +
' Parameter interface is required if there are two or more available \r\n' +
' interfaces on the system. When interface is specified, it cannot be \r\n' +
' a wildcard name.\r\n' +
'\r\n' +
' If the specified interface is already connected to a wireless network,\r\n' +
' this command will first disconnect from the currently connected network,\r\n' +
' then attempt to connect to the new network. However, if these two networks\r\n' +
' are the same this command simply returns success and does nothing.\r\n' +
'\r\n' +
'Examples:\r\n' +
'\r\n' +
' connect name=Profile1 ssid=SSID1\r\n' +
' connect name=Profile2 ssid=SSID2 interface="Wireless Network Connection"\r\n' +
'\r\n',
stderr: ''
}
`
Affected features
[Y] node API
[ ] cli
Possible Solution
I managed to resolve manually in 'windows-connect.js':
In connectToWifi(), changed var cmd = 'cmd to var cmd = 'netsh'
In execCommand(), added shell: true in the execFile() 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)
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="" name="" interface="" and expects no error.
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"
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=] [[ssid=]] [[interface=]] \r\n' +
'\r\n' +
'Parameters:\r\n' +
'\r\n' +
' Tag Value\r\n' +
' ssid - SSID of the wireless network.\r\n' +
' name - Name of the profile to be used in connection attempt.\r\n' +
' interface - Name of the interface from which connection is attempted.\r\n' +
'\r\n' +
'Remarks:\r\n' +
'\r\n' +
' Connect to the wireless network given by ssid using the specified \r\n' +
' profile. Connection is attempted from the specified interface unless \r\n' +
' there is only one available interface on the system, in which case, \r\n' +
' the interface parameter can be omitted.\r\n' +
'\r\n' +
' Parameter profile name is required but ssid is optional. If only one\r\n' +
' SSID exists in the profile, then this SSID is used to connect. If there\r\n' +
' are multiple SSIDs in the profile, then parameter ssid is required.\r\n' +
'\r\n' +
' Parameter interface is required if there are two or more available \r\n' +
' interfaces on the system. When interface is specified, it cannot be \r\n' +
' a wildcard name.\r\n' +
'\r\n' +
' If the specified interface is already connected to a wireless network,\r\n' +
' this command will first disconnect from the currently connected network,\r\n' +
' then attempt to connect to the new network. However, if these two networks\r\n' +
' are the same this command simply returns success and does nothing.\r\n' +
'\r\n' +
'Examples:\r\n' +
'\r\n' +
' connect name=Profile1 ssid=SSID1\r\n' +
' connect name=Profile2 ssid=SSID2 interface="Wireless Network Connection"\r\n' +
'\r\n',
stderr: ''
}
`
Affected features
Possible Solution
I managed to resolve manually in 'windows-connect.js':
connectToWifi()
, changedvar cmd = 'cmd
tovar cmd = 'netsh'
execCommand()
, addedshell: true
in theexecFile()
callSteps to Reproduce (for bugs)
wifi.init({ iface: 'Wi-Fi 2'})
wifi.connect({ ssid: "my_wifi", password: "my_passwd"}, cb)
Context
Your Environment