Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • for /f "tokens=2 delims=:" %%r in ('netsh wlan show interface name=WiFi^|findstr "Channel"') do Set Channel=%%r This will leave a space before the %%r but you shouldn't need to trim it for your use. Add a echo "%Channel%" to see the results. I could write this whole batch file for you but I HIGHLY suggest that you take the tidbit I gave you and solve the rest. Use if /? to figure out the greater than and less than logic. Commented Jan 20, 2022 at 23:10
  • I got it to work if wi-fi is enabled, however, if not enabled I get output "36 was expected at this time." @echo off for /f "tokens=2 delims=:" %%r in ('netsh wlan show interface name=Wi-Fi ^| findstr "Channel"') do Set Channel=%%r if %Channel% GEQ 36 if %Channel% LEQ 177 (echo Wi-Fi 5GHz) else (if %Channel% GEQ 1 if %Channel% LEQ 11 (echo Wi-Fi 2.4GHz) ) if "%Channel%"=="" (echo Wi-Fi not enabled) set "Channel="
    – mnauta
    Commented Jan 21, 2022 at 13:47
  • Thanks @iTwasnTme. I thought of that too. (great minds blah blah blah). I was trying to make it as simple as possible by slightly tweaking his/her code directly as it was. This line runs without error on my machine and I didn't need to escape the eq. Commented Jan 21, 2022 at 15:20