Page 1 of 1

What's the command for connecting/disconnecting to Wifi?

Posted: 20 Oct 2023 06:42
by OM3
I've got a command that I use, it's something like:

netsh wlan connect ssid=wifi_ssid

But now I have a problem. The Wifi on my laptop is gone.
So I've got a USB Wifi dongle. My command doesn't work anymore as it says I need to specify the wifi adapter or something.

I think I can work out how to make it work again.
But I thought I'd try asking here first to find out the 'proper' fool proof way of doing it.

ALSO... I want to have some code that:

- Disconnects from a named Wifi network
- Make it never auto connect to that Wifi network - but keep it in the profile with password still stored

Thanks.

Re: What's the command for connecting/disconnecting to Wifi?

Posted: 21 Oct 2023 03:24
by Batcher
Profile name is mandatory for connect, while ssid and interface are optional.

Code: Select all

netsh wlan connect name="YourProfileName"
C:\>netsh wlan connect /?

Usage: connect [name=]<string> [[ssid=]<string>] [[interface=]<string>]

Parameters:

Tag Value
ssid - SSID of the wireless network.
name - Name of the profile to be used in connection attempt.
interface - Name of the interface from which connection is attempted.
Disconnect by interface name.

Code: Select all

netsh wlan disconnect interface="Your Adapter Name"
C:\>netsh wlan disconnect /?

Usage: disconnect [[interface=]<string>]

Parameters:

Tag Value
interface - Name of the interface from which disconnection is attempted.