Translating Linux shell script to Windows10 MSDOS or Powershell
by P5music from LinuxQuestions.org on (#4S5PK)
Hello,
I managed to create a Linux shell script that is able to switch between two different wifi services that very often hang but which can be manually reconnected with success.
Code:while (true) do
if ! [ "`ping -c 1 -W 1 www.google.it`" ]; then
if (nmcli connection show --active | grep -c "FirstWiFi"); then
nmcli connection up id "SecondWiFi"
echo "switched to SecondWiFi"
else
nmcli connection up id "FirstWiFi"
echo "switched to FirstWiFi"
fi
fi
doneI am not suggesting to use this script because I do not know if it safe.
Now I need the same functionality on a Windows10 system.
I know that MSDOS shell is more limited than the bash shell or the like. But Windows10 has also Powershell.
As you can see the script is very simple so I think it can be translated. I do not know how to do it.
Maybe some easy suggestions can be found here.
Thank you in advance


I managed to create a Linux shell script that is able to switch between two different wifi services that very often hang but which can be manually reconnected with success.
Code:while (true) do
if ! [ "`ping -c 1 -W 1 www.google.it`" ]; then
if (nmcli connection show --active | grep -c "FirstWiFi"); then
nmcli connection up id "SecondWiFi"
echo "switched to SecondWiFi"
else
nmcli connection up id "FirstWiFi"
echo "switched to FirstWiFi"
fi
fi
doneI am not suggesting to use this script because I do not know if it safe.
Now I need the same functionality on a Windows10 system.
I know that MSDOS shell is more limited than the bash shell or the like. But Windows10 has also Powershell.
As you can see the script is very simple so I think it can be translated. I do not know how to do it.
Maybe some easy suggestions can be found here.
Thank you in advance