Connecting to WiFi programmatically - wifi

I want to make a tool for cmd where you specify a password and said and it connects you to the WiFi network. I am aware of the netsh wlan connect command but it use saved wifis
Thanks in advance
-Rob
*edit
Found it was too hard with cmd so I opened up to any other language, any help is appreciated.
*edit2
Found it can be done in batch by writing a custom XML file with the key and ssid, then importing the ssid with the command netsh wlan add profile <path to xml>. Then connect to the imported XML with netsh wlan connect (xml name)
I don't want to answer this officially because I might be wrong

Related

Cannot connect Nano RP2040 Connect running on Micropython to WiFi

I have a Nano RP2040 Connect with Micropython on it. I need to connect it to WiFi. Micropython documentation says I need to import the "network" module, but when I try importing it, I get the no module named 'network' error. I assume the module is only for ESP32 & ESP8266 boards. If anyone has connected to WiFi with a Nano RP2040 Connect on Micropython, please help me out.
P.S.: I have tried CircuitPython, and it worked great, but I need to run a Tensorflow Lite model on my RP2040, and CircuitPython does not have a library for running TFLite, unlike Micropython.

How to connect openWrt (Virtualbox) to wifi?

I'm new user of openWRT I using a internet wifi in Ubuntu 16.04, I installed openWRT in VirtualBox, I tried to connect to internet but I failed, when I try to ping google.com I get this message **bad address google.com **
Just went through the same issue this morning. You have a good documentation in OpenWrt wiki for configuring your OpenWrt network when running over VirtualBox. The information below is all taken from the wiki, but I can assure that is working for a Barrier Breaker running on top of Ubuntu 16.04. The process is as follows:
With your VM off, open the VirtualBox Network tab and make the following configurations:
Configure Adapter 1 to use NAT
Configure Adapter 2 to use Bridge Adapter + Select your host machine's interface from the menu (the one that appears by using
commands as iwconfig or ifconfig). + disable promiscuous
mode
These configurations refer to the following screens (my wireless interface has the name wlx0022.., yours may be different):
Power on your VM and edit /etc/config/network. Change the two interfaces that the wiki mentions (wan and lan) and put them as it is shown below. Your interfaces may have different names before the change (in my case, the wan interface was wan6).
Your /etc/config/network file should look like this:
config 'interface' 'wan'
option 'proto' 'dhcp'
option 'ifname' 'eth0'
config 'interface' 'lan'
#option type 'bridge'
option ifname 'eth1'
#option ip6assign '60'
Just do the changes you need to in order to have your /etc/config/network file as it is shown above, but leaving the other interfaces in the file unchanged (as they are).
Then reboot OpenWrt. After that I was able to connect and ping to any site.
First,change your network connection in VirtualBox to Bridge Mode
Settings --> Network --> Adapter 1 --> Attached to --> Bridged Adapter
Second,modify /etc/config/network in OpenWRT
config interface lan
option ifname eth0
option type bridge
option proto dhcp
Restart your network by this command :
/etc/init.d/network restart
Note: make sure your host (Ubuntu 16.04) is connected to DHCP server.Then your OpenWRT-VirtualBox should get the IP address from it.
If you want to connect WiFi manually by editing file,
you need to edit mainly 3 files.
/etc/config/network
/etc/config/wireless
/etc/config/firewall
--> I would suggest adding the following portion in your network config file(/etc/config/network).
(make sure you do not have any assigned section for the wifi in the network config file)
config interface 'wifi'
option proto 'dhcp'
--> Also, you need to update the file (/etc/config/wireless)
config wifi-iface 'station1'
option device 'radio0'
option ifname 'wlan0'
option mode 'sta'
option network 'wifi'
option disabled '0'
option ssid 'name_of_the_wifi'
option key 'password_of_the_wifi'
option encryption 'encryption_of_wifi_generally_psk2'
in above setup option network 'wifi' "wifi" will be the name of the interface you defines in the /etc/config/network.[make sure if you have above section you edit the existing one. Do not add new section if you do not know what you are doing]
Here, replace "wlan0" with your wireless interface.
If you already have above section in wireless file,
you can also use uci commands as following,
uci set wireless.station1.ssid=name_of_wifi
uci set wireless.station1.key=password
uci set wireless.station1.encryption=psk2
uci commit wireless
wifi down; wifi
here, "station1" would be the name of the section.
--> In the /etc/config/firewall, find the option zone section where all the interface is defined, which looks like following
config zone
option name wan
list network 'wan'
list network 'wan6'
option input REJECT
option output ACCEPT
option forward REJECT
option masq 0
option mtu_fix 1
option conntrack 1
and add
list network 'wwan'
Command to check Wifi Connectivity: iwconfig
Refer the following link:
https://wiki.openwrt.org/doc/uci/wireless
NOTE: PLEASE READ FROM OPENWRT FORUM OR GOOGLE BEFORE DOING ANYTHING
The Wrong configuration may break the OpenWRT connection

Unable to Connect to Wi-Fi using Command Prompt in Windows 8.1

I am unable to connect to Wi-Fi using command prompt. I want to connect to Wi-Fi using command prompt as per my requirement. I can't use GUI controls or any other third party tools for this purpose
Here is what I am doing:
I am adding the wi-fi profile using command:
netsh wlan add profile filename="PATH_TO_FILE.XML" interface="Wi-Fi"
Wi-Fi profile file looks like:
<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>WiFi-ProfileName</name>
<SSIDConfig>
<SSID>
<hex>12346692D57617477617331</hex>
<name>WiFi-SSID</name>
</SSID>
<nonBroadcast>true</nonBroadcast>
</SSIDConfig>
<connectionType>ESS</connectionType>
<connectionMode>auto</connectionMode>
<MSM>
<security>
<authEncryption>
<authentication>WPA2PSK</authentication>
<encryption>AES</encryption>
<useOneX>false</useOneX>
</authEncryption>
<sharedKey>
<keyType>passPhrase</keyType>
<protected>true</protected>
<keyMaterial>KEY_IS_REMOVED_TO_SHOW_THE_FILE_OF_THE_CONTENT_HERE</keyMaterial>
</sharedKey>
</security>
</MSM>
</WLANProfile>
To connect to Wi-Fi network using I am using command:
netsh wlan connect ssid="WiFi-SSID" name="WiFi-ProfileName" interface="Wi-Fi"
After running this command, command prompt is showing a message that Connection request was completed successfully, but machine is not connecting the Wi-Fi at all.
Am I missing some setting to set any kind of permission or its something else?

"Group & resources are not in correct state" error in virtual router

When I make wifi hot spot through Virtual router on laptop, Its work fine but when I go through my Desktop it syas "Group & resources are not in correct state". I using n 150 micro adapter in my destop PC. Does Virtual router not support to external wifi adapter. Please help me to solve this.
Open an elevated Command Prompt window
Run:
netsh wlan set hostednetwork mode=allow

" netsh wlan start hostednetwork " command not working no matter what I try

C:\Windows\system32>netsh wlan show drivers
Interface name: Wireless Network Connection
Driver : DW1501 Wireless-N WLAN Half-Mini Card
Vendor : Broadcom
Provider : Broadcom
Date : 21/01/2010
Version : 5.60.48.35
INF file : C:\Windows\INF\oem26.inf
Files : 5 total
C:\Windows\system32\DRIVERS\BCMWL6.SYS
C:\Windows\system32\bcmihvsrv.dll
C:\Windows\system32\bcmihvui.dll
C:\Windows\system32\drivers\vwifibus.sys
C:\Windows\system32\bcmwlcoi.dll
Type : Native Wi-Fi Driver
Radio types supported : 802.11n 802.11g 802.11b
FIPS 140-2 mode supported : Yes
Hosted network supported : Yes
Authentication and cipher supported in infrastructure mode:
Open None
Open WEP
Shared None
Shared WEP
WPA2-Enterprise TKIP
WPA2-Personal TKIP
WPA2-Enterprise CCMP
WPA2-Personal CCMP
WPA2-Enterprise Vendor defined
WPA2-Enterprise Vendor defined
Vendor defined Vendor defined
Vendor defined Vendor defined
Vendor defined TKIP
Vendor defined CCMP
WPA-Enterprise TKIP
WPA-Personal TKIP
WPA-Enterprise CCMP
WPA-Personal CCMP
Authentication and cipher supported in ad-hoc mode:
WPA2-Personal CCMP
Open None
Open WEP
IHV service present : Yes
IHV adapter OUI : [00 10 18], type: [00]
IHV extensibility DLL path: C:\Windows\System32\bcmihvsrv.dll
IHV UI extensibility ClSID: {aaa6dee9-31b9-4f18-ab39-82ef9b06eb73}
IHV diagnostics CLSID : {00000000-0000-0000-0000-000000000000}
I disabled and re-enabled it many times. Still no clue whats goin wrong I always get the error saying
"C:\Windows\system32>netsh wlan start hostednetwork
The hosted network couldn't be started.
A device attached to the system is not functioning."
The commands before that are running perfectly. The virtual adapter and everything is also enabled.
netsh wlan show hostednetwork
C:\Windows\system32> netsh wlan show hostednetwork
Hosted network settings
Mode : Allowed
SSID name : "Lathiyas"
Max number of clients : 100
Authentication : WPA2-Personal
Cipher : CCMP
Hosted network status
Status : Not started
Then tried stopping the hostednetwork and tried again still the same error. I think there is some problem with the drivers. Dell N5010 Windows 7-32bit system. Please help.
First of all go to the device manager now go to View>>select Show hidden devices....Then go to network adapters and find out Microsoft Hosted network Virual Adapter ....Press right click and enable the option....
Then go to command prompt with administrative privileges and enter the following commands:
netsh wlan set hostednetwork mode=allow
netsh wlan start hostednetwork
Your Hostednetwork will work without any problems.
At first simply uninstall wifi drivers and softwares
just keep wifi drivers
+
from device manager....network adapters...remove all virtual connections
then
Press the Windows + R key combination to bring up a run box, type ncpa.cpl and hit enter.
netsh wlan set hostednetwork mode=allow ssid=”How-To Geek” key=”Pa$$w0rd”
netsh wlan start hostednetwork
netsh wlan show hostednetwork
its working for me and on others PC.
Same issue.
I solved the problem first activating (right click mouse and select activate) from control panel (network connections) and later changing to set mode to allow (by netsh command), to finally starting the hostednetwork with other netsh command, that is:
1.- Activate (Network Connections) by right click
2.- netsh wlan set hostednetwork mode=allow
3.- netsh wlan start hosted network
Good luck mate !!!
If none of the above solution worked for you, locate the Wifi adapter from "Control Panel\Network and Internet\Network Connections", right click on it, and select "Diagnose", then follow the given instructions on the screen. It worked for me.
netsh wlan set hostednetwork mode=allow ssid=dhiraj key=7870049877
If you have a wifi button or switch on your laptop make sure it is turned on! Then use the netsh commands that other people have stated
This was a real issue for me, and quite a sneaky problem to try and remedy...
The problem I had was that a module that was installed on my WiFi adapter was conflicting with the Microsoft Virtual Adapter (or whatever it's actually called).
To fix it:
Hold the Windows Key + Push R
Type: ncpa.cpl in to the box, and hit OK.
Identify the network adapter you want to use for the hostednetwork, right-click it, and select Properties.
You'll see a big box in the middle of the properties window, under the heading The connection uses the following items:. Look down the list for anything that seems out of the ordinary, and uncheck it. Hit OK.
Try running the netsh wlan start hostednetwork command again.
Repeat steps 4 and 5 as necessary.
In my case my adapter was running a module called SoftEther Lightweight Network Protocol, which I believe is used to help connect to VPN Gate VPN servers via the SoftEther software.
If literally nothing else works, then I'd suspect something similar to the problem I encountered, namely that a module on your network adapter is interfering with the hostednetwork aspect of your driver.

Resources