2

I'd like to see the wireless signal strength (preferably, via dbm or %) in Windows 7 via command line.

Here's what I've tried:

1) VBscript using MSNdis_80211_ReceivedSignalStrength (but only works in pre-Vista versions)

2) Command line using "netsh wlan show interfaces"

Ideally, I'd like to collect it over some period of time and average it. This, I know, isn't possible through a straight command line execution, so I'm willing to cede that possibility if I can merely get only the signal strength in percent (%).

1

After much internal infighting, I utilized a combination of VBScript and command line. Since there doesn't appear to be a WMI methodology to grab the signal strength anymore, and since I'd prefer to collect the information over a short period of time and average it, I'm using VBScript to execute NETSH and pull the data I need.

This could absolutely be quickly modified to repeat endlessly so you could walk around with your laptop to determine signal strength in different areas (although, absolutely not recommended because far superior 3rd-party software packages exist).

====================================================================

dim obj_shell, obj_cmdexectestWLAN, var_line, obj_cmdexec, var_signalstrength, var_testinterval, var_counter, var_dots, var_arraycontents, var_item, var_average, var_multiplier, arr_signalstrength()
var_testinterval = 1000 'in milliseconds
var_counter = 0
var_dots = "." 'this is for a cheap progress bar

set obj_shell = wscript.createobject("WScript.Shell")
set obj_cmdexectestWLAN = obj_shell.exec("%comspec% /C netsh wlan show interfaces")
var_line = obj_cmdexectestWLAN.stdout.readline()
if instr(var_line, "not running") = 0 then

    function func_getwirelesssignalstrength()
        set obj_cmdexec = obj_shell.Exec("%comspec% /C netsh wlan show interfaces | FIND ""Signal""")
        var_line = obj_cmdexec.stdout.readline()
        var_line = replace(var_line,"Signal                 : ","")
        var_line = replace(var_line,"%","")
        var_line = trim(var_line)
        if isnumeric(var_line) then 
            func_getwirelesssignalstrength = var_line
        else
            func_getwirelesssignalstrength = "Error"
        end if
    end function

    do while var_counter < 10 '0-based. Gives us 10 samples. If you want a longer interval, you can modify both 'var_counter' at the top and this as well
        wscript.stdout.write(var_dots & chr(13))
        var_signalstrength = func_getwirelesssignalstrength()
        if isnumeric(var_signalstrength) then
            if var_counter = 0 then
                redim arr_signalstrength(0)
                arr_signalstrength(0) = var_signalstrength
            else
                redim preserve arr_signalstrength(ubound(arr_signalstrength) + 1)
                arr_signalstrength(ubound(arr_signalstrength)) = var_signalstrength
            end if
            var_counter = var_counter + 1
            var_dots = var_dots & "."
            wscript.sleep var_testinterval
        else
            wscript.echo("Error: Non-numeric value received from NETSH. Quitting...")
            wscript.quit
        end if
    loop

    for each var_item in arr_signalstrength
        var_arraycontents = var_arraycontents & var_item & ","
        var_multiplier = cint(var_multiplier) + cint(var_item)
    next
    var_average = var_multiplier/var_counter
    'wscript.echo("Multiplier:" & var_multiplier & vbcrlf & "Counter:" & var_counter & vbcrlf & "Average:" & var_average & vbcrlf & "Average Rounded:" & round(var_average,2)) 'test region to see our output in more detail
    wscript.echo("Values Received: " & var_arraycontents) 'test region to see our array contents
    wscript.echo("Signal Strength Average: " & round(var_average,2))

else
    wscript.echo("Error: WLAN Service Not Running")
    wscript.quit
end if
  • netsh wlan show networks mode=bssid – Mayank Mar 27 '15 at 7:52
  • While beneficial in some scenarios, your command shows all visible networks rather than the currently-joined. Using my posted VBScript with the command you listed won't work, as your command may return a large number of results, which the code is not currently set to handle. – Beems Mar 27 '15 at 14:43
  • In regards to the first line under the "do while" declaration, which is to say the "wscript.stdout.write" line, anybody know why I would get an invalid handle error in reference to this line? – Mike Mounier Jan 13 '17 at 20:43
  • @Mike In that case, specifically, you would need to make sure you have the "var_dots" variable defined (currently line 4) – Beems Jan 17 '17 at 21:11
  • 1
    @MikeMounier stdout is only accessible by cscript, but wscript. Open up command line and type cscript nameOfYourFile.vbs – LostInTheCode Mar 11 '17 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.