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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
OM3
Posts: 32
Joined: 17 Mar 2014 08:43

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

#1 Post by OM3 » 20 Oct 2023 06:42

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.

Batcher
Posts: 74
Joined: 16 Apr 2009 10:36

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

#2 Post by Batcher » 21 Oct 2023 03:24

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.

Post Reply