1

Is there a way to schedule window connect to any network if it available by using command prompt or powershell?

Here is the scenario:

My computer need to connect to a network 24/24 I have 3 wifi networks

  1. Wifi-Guest
  2. Wifi-Staff1
  3. Wifi-Staff2

My computer are allowed to connect all three networks above. It will connect to another network if one of them - which is I connecting are unavailable in case of the "Connect automatically" option are not worked.

So, the question is: How to connect or switch wifi from my network list by using command prompt or powershell if my computer disconnect or no internet from current wifi?

3
  • Connecting should be automatic if the computer has previously connected to all of them.
    – harrymc
    Commented Aug 8, 2022 at 14:31
  • @harrymc in my case, driver conflict with windows cause a bug that wifi not connect automatically. As I mentioned above: "Connect automatically" option are not worked.
    – Antonio
    Commented Aug 10, 2022 at 13:15
  • In this case, you should look for a better driver or another network adapter.
    – harrymc
    Commented Aug 10, 2022 at 14:01

1 Answer 1

0

I would accomplish this with a loop testing your network connection. If it fails, log into the other adapter:

while ($true){

$connection = Test-Connection 8.8.8.8 -count 2

if($connection -eq $null){
$wifiguest = netsh wlan connect ssid="Wifi-Guest" name="YOUR_Profile"

    if ($wifiguest -ne "Connection request was completed successfully."){
    $wifistaff1 = netsh wlan connect ssid="Wifi-Staff1" name="YOUR_Profile"
    }

    if ($wifistaff1 -ne "Connection request was completed successfully."){
    $wifistaff1 = netsh wlan connect ssid="Wifi-Staff12" name="YOUR_Profile"
    }

}
write-host "Sleeping" 
Start-Sleep -s 5
}

The profile is the saved credentials for the network (assuming you've already signed in. If you don't know your profile/s, you can check it like this:

netsh wlan show profile

You can change the follow as well:

  • 8.8.8.8 (Doesn't have to be Google.)
  • -count (default is 4. I lowered it)
  • start-sleep: 5 can be changed to your timeout preference in seconds.
1
  • 1
    This worked for me, thanks!
    – Antonio
    Commented Aug 13, 2022 at 11:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .