Problem with porting VBScript from WinXP to Win7
The attached VBScript displays all available WiFi networks.
It works fine on WinXP, but doesn't work on Win7. On WinXP it shows a list of all available WiFi networks, however on WIn7 it 开发者_StackOverflow中文版shows 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 a newbie with VBScript so please be gentle.
[I would comment, but not enough rep :P] Visual Studio will allow you to debug a VBScript so you can determine which line in particular is causing the issue.
Navigate to the directory that contains the script, then run 'wscript .vbs //D //X' and then select Visual Studio as your debugger. You can then run through each line and get an idea of what is happening (source).
When I execute this script (both with normal and elevated privileges) I receive an empty array from the query "SELECT * FROM MSNDis_80211_BSSIList". This may be where the issue is stemming from; maybe having the source (MSNDis_80211_BSSIList) deprecated and renamed in Windows 7.
A Google also revealed a possible correlation between the latest set of drivers (such as the Intel Wifi drivers) which may contain the WMI additions.
精彩评论