0

So I have issues with my wlan.

My wlan looses connection and I have to connect to it manually.

So now I want a program that connects me to my wlan if I´m not connected to it.

( I'm very new at cmd)

Here is my code that I have right now.

:restart

netsh wlan show interfaces | findstr "MYWLAN"
IF %ERRORLEVEL% EQU 0 GOTO connected

:connected
netsh wlan connect name=MYWLAN

timeout /T 1

GOTO restart

Right now, when I let the program run, I lose my wlan connection but i dont know what is wrong

Markus
  • 52
  • 6
  • 2
    In your current code, regardless of whether the error level is 0 or 1, it will still reach `:connected` and run the connection command. – Martheen Sep 11 '22 at 19:07
  • oh ok I will try to find the correct statement that I want. Do you know what statement I would need – Markus Sep 11 '22 at 19:20
  • 1
    https://stackoverflow.com/questions/25384358/batch-if-elseif-else – Martheen Sep 11 '22 at 19:23
  • …or just place `goto :EOF` after the `if` statement to leave the batch file if the `ErrorLevel` is not zero (or `goto` another label)… – aschipfl Sep 11 '22 at 20:45

0 Answers0