JackKirk Well-Known Member Licensed User Longtime User Feb 6, 2019 #1 This is driving me balmy. I'm using the jShell library to do some wifi massaging on a Windows 10 PC, one code snippet is: Code: Private wrk_sh As Shell Private wrk_args As List wrk_args.Initialize 'Set up shell to disconnect WiFi interface on PC wrk_args.Add("/c") wrk_args.Add("netsh wlan disconnect interface=" & wrk_interface & " > d:\Swamp\BufferFTPClient-WiFi-Disconnect.txt") wrk_sh.Initialize("Event_shell2", "cmd.exe", wrk_args) wrk_sh.Run(10000) If the variable wrk_interface contains no blanks (e.g. "Wi-Fi") then all works fine. If the variable wrk_interface contains a blank (e.g. "Wi-Fi 4") then it dies with message: One or more parameters for the command are not correct or missing. Usage: disconnect [[interface=]<string>] Parameters: Tag Value interface - Name of the interface from which disconnection is attempted. Remarks: Disconnect from the wireless network on the specified interface. Parameter interface is required if there are two or more available interfaces on the system. Wildcard characters can be used in the interface name to specify multiple interfaces. Examples: disconnect disconnect interface="Wireless Network Connection" Click to expand... If I try putting in double quotes like: wrk_args.Add("netsh wlan disconnect interface=""" & wrk_interface & """ > d:\Swamp\BufferFTPClient-WiFi-Disconnect.txt") then it dies with message: Error after shell wait (WiFi Disconnect)... Success: true ExitCode: 1 StdOut: StdErr: ''netsh' is not recognized as an internal or external command, operable program or batch file. Click to expand... I've scoured the forums for the last 2 hours and didn't find anything that worked. Any pointers to the probably incredibly stupid thing I am/am not doing greatly appreciated... Last edited: Feb 6, 2019
This is driving me balmy. I'm using the jShell library to do some wifi massaging on a Windows 10 PC, one code snippet is: Code: Private wrk_sh As Shell Private wrk_args As List wrk_args.Initialize 'Set up shell to disconnect WiFi interface on PC wrk_args.Add("/c") wrk_args.Add("netsh wlan disconnect interface=" & wrk_interface & " > d:\Swamp\BufferFTPClient-WiFi-Disconnect.txt") wrk_sh.Initialize("Event_shell2", "cmd.exe", wrk_args) wrk_sh.Run(10000) If the variable wrk_interface contains no blanks (e.g. "Wi-Fi") then all works fine. If the variable wrk_interface contains a blank (e.g. "Wi-Fi 4") then it dies with message: One or more parameters for the command are not correct or missing. Usage: disconnect [[interface=]<string>] Parameters: Tag Value interface - Name of the interface from which disconnection is attempted. Remarks: Disconnect from the wireless network on the specified interface. Parameter interface is required if there are two or more available interfaces on the system. Wildcard characters can be used in the interface name to specify multiple interfaces. Examples: disconnect disconnect interface="Wireless Network Connection" Click to expand... If I try putting in double quotes like: wrk_args.Add("netsh wlan disconnect interface=""" & wrk_interface & """ > d:\Swamp\BufferFTPClient-WiFi-Disconnect.txt") then it dies with message: Error after shell wait (WiFi Disconnect)... Success: true ExitCode: 1 StdOut: StdErr: ''netsh' is not recognized as an internal or external command, operable program or batch file. Click to expand... I've scoured the forums for the last 2 hours and didn't find anything that worked. Any pointers to the probably incredibly stupid thing I am/am not doing greatly appreciated...
TnP Member Licensed User Longtime User Feb 6, 2019 #2 One potential work around is to put what you need in a .bat file then use Shell to run the .bat instead. I've been working on something similar recently and it worked for me. Upvote 0
One potential work around is to put what you need in a .bat file then use Shell to run the .bat instead. I've been working on something similar recently and it worked for me.
JackKirk Well-Known Member Licensed User Longtime User Feb 6, 2019 #3 TnP, I thought of that but things are messy enough already, I'm hoping there is a cleaner solution. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Feb 6, 2019 #4 It is possible that creating a batch file will be the simplest solution. Try to use Shell.InitializeDoNotHandleQuotes. Upvote 0
It is possible that creating a batch file will be the simplest solution. Try to use Shell.InitializeDoNotHandleQuotes.
Daestrum Expert Licensed User Longtime User Feb 6, 2019 #5 Shouldn't the wrk_args be Code: wrk_args.AddAll(Array("/C","netsh","wlan","disconnect",$"interface="${wrk_interface}""$,">","d:\Swamp\BufferFTPClient-WiFi-Disconnect.txt")) Upvote 0
Shouldn't the wrk_args be Code: wrk_args.AddAll(Array("/C","netsh","wlan","disconnect",$"interface="${wrk_interface}""$,">","d:\Swamp\BufferFTPClient-WiFi-Disconnect.txt"))
JackKirk Well-Known Member Licensed User Longtime User Feb 6, 2019 #6 I am overwhelmed by the support that these forums provide - 3 useful responses in 5 hours. Erel said: Try to use Shell.InitializeDoNotHandleQuotes. Click to expand... Erel's suggestion works a treat, the code snippet in post #1 becomes: Code: Private wrk_sh As Shell Private wrk_args As List wrk_args.Initialize 'Set up shell to disconnect WiFi interface on PC wrk_args.Add("/c") wrk_args.Add("netsh wlan disconnect interface=""" & wrk_interface & """ > ""d:\Swamp\BufferFTPClient WiFi Disconnect.txt""") wrk_sh.InitializeDoNotHandleQuotes("Event_shell2", "cmd.exe", wrk_args) wrk_sh.Run(10000) Which is the way I would have thought it should work with wrk_sh.Initialize I can even name my pipe file as d:\Swamp\BufferFTPClient WiFi Disconnect.txt which is what I wanted originally but could not get to work because of the embedded blanks. Which all raises a further question - why is wrk_sh_Initialize the "default" when it is doing crazies with the parameters? Last edited: Feb 6, 2019 Upvote 0
I am overwhelmed by the support that these forums provide - 3 useful responses in 5 hours. Erel said: Try to use Shell.InitializeDoNotHandleQuotes. Click to expand... Erel's suggestion works a treat, the code snippet in post #1 becomes: Code: Private wrk_sh As Shell Private wrk_args As List wrk_args.Initialize 'Set up shell to disconnect WiFi interface on PC wrk_args.Add("/c") wrk_args.Add("netsh wlan disconnect interface=""" & wrk_interface & """ > ""d:\Swamp\BufferFTPClient WiFi Disconnect.txt""") wrk_sh.InitializeDoNotHandleQuotes("Event_shell2", "cmd.exe", wrk_args) wrk_sh.Run(10000) Which is the way I would have thought it should work with wrk_sh.Initialize I can even name my pipe file as d:\Swamp\BufferFTPClient WiFi Disconnect.txt which is what I wanted originally but could not get to work because of the embedded blanks. Which all raises a further question - why is wrk_sh_Initialize the "default" when it is doing crazies with the parameters?
Erel B4X founder Staff member Licensed User Longtime User Feb 6, 2019 #7 Your usage is not standard. In most cases each argument is added as a separate entry. This case is more complicated as you are actually starting cmd.exe which then starts another process. Upvote 0
Your usage is not standard. In most cases each argument is added as a separate entry. This case is more complicated as you are actually starting cmd.exe which then starts another process.
JackKirk Well-Known Member Licensed User Longtime User Feb 6, 2019 #8 Erel said: Your usage is not standard. Click to expand... Erel, you may be right but I have only ever used jShell to run cmd.exe - admittedly with much simpler arguments in the past. Upvote 0
Erel said: Your usage is not standard. Click to expand... Erel, you may be right but I have only ever used jShell to run cmd.exe - admittedly with much simpler arguments in the past.