I'm trying to detect the SSID that my Windows 10 laptop is connected to, and deciding what to do based on the detected SSID. I'm able to detect the SSID via the following command:
netsh wlan show interfaces | findstr /r "^....SSID"
This command output is as such:
SSID :my_ssid
I'm trying to assign this string output to a variable with the following command:
set ssid=
for /f %%i in ('netsh wlan show interfaces | findstr /r "^....SSID"') do set ssid=%%i
echo SSID is "%ssid%"
However, I keep getting the following error message:
| was unexpected at this time.
Does anyone know why?
Also, is it possible to strip the netsh output of the "SSID", ":" and the whitespace so that I get only "my_ssid" as the output?