Skip to main content

How to Get the Wi-Fi Signal Strength in Batch Script

In a world where connectivity is everything, being able to programmatically monitor your wireless signal quality is an incredibly useful skill. Whether you are building a diagnostic tool to check connection stability or a script that switches to a wired connection if the Wi-Fi drops below a certain threshold, knowing the exact signal percentage is the first step.

This guide will explain how to use the netsh command to extract the Wi-Fi signal strength and store it in a Batch variable for further logic, with scripts that work across all Windows display languages.

The Source of the Data: Netsh WLAN

Windows provides all necessary wireless information through the Network Shell (netsh). The command netsh wlan show interfaces displays detailed metrics about your active wireless connection, including the SSID, radio type, and the Signal strength as a percentage.

Basic Retrieval Command

Running this command in a standard prompt produces a block of text:

netsh wlan show interfaces

Partial Output:

Radio type : 802.11ax
Authentication : WPA3-Personal
Cipher : CCMP
Connection mode : Auto Connect
Band : 5 GHz
Channel : 36
Receive rate (Mbps) : 1201
Transmit rate (Mbps) : 1201
Signal : 99%
Profile : MyHomeWiFi

The key challenge is that the label "Signal" is translated on non-English Windows (e.g., "Segnale" in Italian, "Señal" in Spanish, "Sinal" in Portuguese). However, the value format, a number followed by %, is the same in every language. And critically, the Signal line is the only line in the netsh wlan show interfaces output that contains the % character. This gives us a reliable, language-independent way to identify it.

Method 1: Language-Independent Signal Extraction

This script matches the % character instead of the word "Signal", making it work on any Windows display language.

@echo off
setlocal enabledelayedexpansion

set "strength="

rem --- Verify the Wireless AutoConfig service is running ---
sc query WlanSvc 2>nul | findstr /i /c:"RUNNING" >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] The Wireless AutoConfig service is not running.
echo [INFO] This machine may not have a Wi-Fi adapter.
endlocal
pause
exit /b 1
)

rem --- Extract signal strength ---
rem --- The Signal line is the ONLY line in netsh output containing %% ---
rem --- In batch files: %%%% becomes %%, which findstr sees as literal %% ---
for /f "tokens=1,* delims=:" %%a in (
'netsh wlan show interfaces 2^>nul ^| findstr "%%"'
) do (
if not defined strength (
set "raw=%%b"
if defined raw (
rem --- Remove all spaces ---
set "strength=!raw: =!"
rem --- Remove the percent sign ---
rem --- Batch parser: %%%% becomes %%, delayed expansion replaces %% with nothing ---
set "strength=!strength:%%=!"
)
)
)

if not defined strength (
echo [ERROR] Could not detect Wi-Fi signal strength.
echo [INFO] Wi-Fi may be disabled or not connected to any network.
endlocal
pause
exit /b 1
)

echo Current Wi-Fi Signal Strength: !strength!%%

endlocal
pause

How the % handling works, step by step:

The % character has special meaning in Batch files (variable expansion), so every interaction with a literal % requires careful escaping.

  1. Finding the line: findstr "%%" the batch parser converts %% to a single %, so findstr receives findstr "%" and matches lines containing a literal % sign. Since only the Signal line has %, this is language-independent.

  2. Removing % from the value: set "strength=!strength:%%=!" the batch parser converts %% to % in the first pass, producing !strength:%=!. Then delayed expansion processes this as "replace % with nothing in the variable strength".

  3. Displaying with %: echo ... !strength!%% the batch parser converts %% to %, and delayed expansion replaces !strength! with the numeric value. Output: 99%.

info

Why match % instead of "Signal"? The label text changes with the Windows display language, "Signal" in English and German, "Segnale" in Italian, "Señal" in Spanish, "Sinal" in Portuguese, and completely different characters in Asian languages. The % sign in the value, however, is present in every language. Since no other line in the netsh wlan show interfaces output contains %, it serves as a unique, language-independent identifier for the signal strength line.

Method 2: Connection Quality Monitor

You can use the numeric signal strength to trigger actions based on thresholds, warning users about poor connections or switching behavior based on signal quality.

@echo off
setlocal enabledelayedexpansion

set "strength="

rem --- Verify Wi-Fi service ---
sc query WlanSvc 2>nul | findstr /i /c:"RUNNING" >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] Wireless AutoConfig service is not running.
endlocal
pause
exit /b 1
)

rem --- Extract signal strength (language-independent) ---
for /f "tokens=1,* delims=:" %%a in (
'netsh wlan show interfaces 2^>nul ^| findstr "%%"'
) do (
if not defined strength (
set "raw=%%b"
if defined raw (
set "strength=!raw: =!"
set "strength=!strength:%%=!"
)
)
)

if not defined strength (
echo [ERROR] No Wi-Fi signal detected. Are you connected?
endlocal
pause
exit /b 1
)

echo [AUDIT] Signal Strength: !strength!%%
echo.

rem --- Evaluate connection quality using numeric thresholds ---
rem --- LSS = Less Than (numeric comparison) ---
if !strength! LSS 30 (
echo [WARNING] Very poor connection. Consider moving closer to the router
echo or switching to a wired connection.
) else if !strength! LSS 60 (
echo [INFO] Fair connection. Performance may be degraded for large transfers.
) else if !strength! LSS 80 (
echo [OK] Good connection. Suitable for most tasks.
) else (
echo [OK] Excellent connection.
)

endlocal
pause

Method 3: Targeting a Specific Wi-Fi Adapter

If your computer has multiple wireless adapters (e.g., an internal card and a USB dongle), netsh wlan show interfaces lists all of them. The basic script captures only the first signal value it finds. To target a specific adapter, use the interface= parameter.

@echo off
setlocal enabledelayedexpansion

set "AdapterName=Wi-Fi 2"
set "strength="

rem --- Verify Wi-Fi service ---
sc query WlanSvc 2>nul | findstr /i /c:"RUNNING" >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] Wireless AutoConfig service is not running.
endlocal
pause
exit /b 1
)

rem --- Verify the specified adapter exists ---
netsh wlan show interfaces 2>nul | findstr /i /c:"%AdapterName%" >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] Adapter "%AdapterName%" not found.
echo [INFO] Available wireless interfaces:
netsh wlan show interfaces
endlocal
pause
exit /b 1
)

rem --- Extract signal strength for the specific adapter ---
rem --- The interface= parameter filters output to one adapter ---
for /f "tokens=1,* delims=:" %%a in (
'netsh wlan show interfaces interface^="%AdapterName%" 2^>nul ^| findstr "%%"'
) do (
if not defined strength (
set "raw=%%b"
if defined raw (
set "strength=!raw: =!"
set "strength=!strength:%%=!"
)
)
)

if not defined strength (
echo [ERROR] No signal detected on "%AdapterName%".
echo [INFO] The adapter may not be connected to any network.
) else (
echo Adapter: %AdapterName%
echo Signal: !strength!%%
)

endlocal
pause

Finding adapter names: Run netsh wlan show interfaces and look for the Name field. Common names include Wi-Fi, Wi-Fi 2, Wireless Network Connection, or custom names set by the user. Adapter names are not translated, they are either Windows defaults or user-defined.

Method 4: Continuous Signal Monitor

This script checks the signal strength at regular intervals and logs drops below a threshold. Useful for diagnosing intermittent connectivity issues or monitoring remote kiosks.

@echo off
setlocal enabledelayedexpansion

set "Threshold=40"
set "Interval=30"
set "LogFile=%~dp0signal_monitor.log"

rem --- Verify Wi-Fi service ---
sc query WlanSvc 2>nul | findstr /i /c:"RUNNING" >nul 2>&1
if %errorlevel% neq 0 (
echo [ERROR] Wireless AutoConfig service is not running.
endlocal
pause
exit /b 1
)

echo [MONITOR] Wi-Fi Signal Strength Monitor
echo [MONITOR] Threshold: %Threshold!%% Interval: %Interval%s
echo [MONITOR] Log file: %LogFile%
echo [MONITOR] Press Ctrl+C to stop.
echo.

:CheckLoop
set "strength="

rem --- Extract current signal ---
for /f "tokens=1,* delims=:" %%a in (
'netsh wlan show interfaces 2^>nul ^| findstr "%%"'
) do (
if not defined strength (
set "raw=%%b"
if defined raw (
set "strength=!raw: =!"
set "strength=!strength:%%=!"
)
)
)

if not defined strength (
echo [!time!] NO SIGNAL - Wi-Fi disconnected
echo !date! !time! - NO SIGNAL - disconnected >> "!LogFile!"
goto :Wait
)

rem --- Display current reading ---
if !strength! LSS %Threshold% (
echo [!time!] WARNING - Signal: !strength!%% ^(below %Threshold!%%^)
echo !date! !time! - LOW SIGNAL: !strength!%% >> "!LogFile!"
) else (
echo [!time!] OK - Signal: !strength!%%
)

:Wait
timeout /t %Interval% /nobreak >nul
goto :CheckLoop

How to Avoid Common Errors

Wrong Way: Searching for the Word "Signal"

The word "Signal" is translated in non-English Windows versions. A script that matches this label will fail silently on machines with different display languages.

rem *** BAD: fails on Italian, Spanish, Portuguese, Asian languages ***
netsh wlan show interfaces | findstr "Signal"

Correct Way: Match the % character, which is language-independent and unique to the Signal line.

rem *** GOOD: works in every language ***
netsh wlan show interfaces | findstr "%%"

Wrong Way: Removing % with Standard Variable Substitution

The % character is the variable expansion operator in Batch. Trying to remove it with standard %var:old=new% syntax produces unpredictable results because the parser misinterprets the % signs.

rem *** BAD: the parser cannot distinguish between variable syntax and literal %% ***
set "strength=%strength:%=%"

Correct Way: Use delayed expansion, where ! is the expansion operator and % is treated as a regular character (after the %%% conversion in the first parsing pass).

rem *** GOOD: delayed expansion handles %% correctly ***
set "strength=!strength:%%=!"

Wrong Way: Using the Numeric Value Without Checking It Exists

If Wi-Fi is disconnected or the adapter is off, the signal variable will be empty. Using it in a numeric comparison like if %sig% LSS 30 causes a syntax error.

rem *** BAD: crashes if sig is empty ***
if %sig% LSS 30 echo Poor signal

Correct Way: Always verify the variable is defined before using it in comparisons.

rem *** GOOD: safe check ***
if not defined strength (
echo No signal detected.
) else if !strength! LSS 30 (
echo Poor signal.
)

Troubleshooting: Why Is the Variable Empty?

If your script returns an empty strength value, check these common causes:

  1. Wi-Fi radio is off: If the wireless adapter is disabled (hardware switch, airplane mode, or software disable), netsh wlan show interfaces reports no active interface and the Signal line does not appear.

  2. Not connected to a network: If Wi-Fi is enabled but not connected to any SSID, the interface status shows disconnected and no Signal line is present.

  3. No wireless adapter: On desktops without a Wi-Fi card, the Wireless AutoConfig service (WlanSvc) may not be running at all.

  4. Multiple adapters: If you have two wireless adapters and the first one is disconnected, the basic script may find the % line from the second adapter. Use Method 3 to target a specific adapter.

Best Practices and Rules

1. The % Sign Is Your Language-Independent Anchor

The Signal value's % sign is present in every Windows language and is unique to the Signal line in the netsh output. Use it as your matching pattern instead of any translated label text.

2. Always Use Delayed Expansion for % Manipulation

The % character is the variable expansion operator in Batch. You cannot reliably use it in standard %var:find=replace% substitution. Delayed expansion (!var:%%=! after the first parsing pass) is the only reliable way to manipulate strings containing %.

3. Validate Before Comparing

Always check if not defined before using the signal value in numeric comparisons. An undefined variable in a LSS or GTR comparison causes a Batch syntax error that terminates the script.

4. Signal Strength Is Relative

The percentage reported by Windows is not an absolute measurement, it is a relative assessment by the wireless driver. A reading of 80% on one adapter may correspond to a different actual signal level than 80% on a different adapter model. Use thresholds as guidelines, not absolute rules.

5. Use setlocal / endlocal

Always wrap scripts in setlocal and endlocal to prevent variables from leaking into the calling environment.

Conclusions

Extracting Wi-Fi signal strength in a Batch script is fundamentally a string-parsing exercise complicated by the % character's dual role as both the signal unit and the Batch variable operator. The solution is twofold: use the % sign itself as a language-independent line identifier (since it appears only on the Signal line), and use delayed expansion to safely strip it from the value. With these techniques, you can build quality monitors, threshold-based automations, and continuous diagnostics that work reliably on any Windows machine, in any language.