Problem with porting VBScript from WinXP to Win7

The included VBScript displays all available WiFi networks.
It works fine on WinXP, but does not work on Win7. WinXP displays a list of all available Wi-Fi networks, but WIn7 displays an empty list. What is the problem?

on error resume next set objSWbemServices = GetObject("winmgmts:\\.\root\wmi") set colInstances = objSwbemServices.ExecQuery("SELECT * FROM MSNDis_80211_BSSIList") for each obj in colInstances if left(obj.InstanceName, 4) <> "WAN " and right(obj.InstanceName, 8) <> "Miniport" then for each rawssid in obj.Ndis80211BSSIList ssid = "" for i=0 to ubound(rawssid.Ndis80211SSid) decval = rawssid.Ndis80211Ssid(i) if (decval > 31 AND decval < 127) then ssid = ssid & Chr(decval) end if next wscript.echo ssid next end if next 

I am new to VBScript, so please be careful.

+4
source share
1 answer

[I would comment, but not enough rep: P] Visual Studio will let you debug VBScript so that you can determine which line in particular is causing the problem.

Change to the directory containing the script, then run 'wscript.vbs // D // X' and then select Visual Studio as the debugger. Then you can run each line and get an idea of ​​what is happening ( source ).

When I execute this script (both with normal and elevated privileges), I get an empty array from the query "SELECT * FROM MSNDis_80211_BSSIList". This may be the problem that causes the problem; the source (MSNDis_80211_BSSIList) may be outdated and renamed to Windows 7.

Google also revealed a possible correlation between the latest set of drivers (for example, Intel Wifi drivers), which may contain WMI add-ons.

+3
source

Source: https://habr.com/ru/post/1300549/


All Articles