obtain info about wireless connection

Discussion in 'Wireless Networking' started by myspacee, Aug 14, 2008.

  1. myspacee

    myspacee Guest

    hello,
    i've a request.

    with vbs script, Is possible to obtain info about wireless connection ?

    Need :
    - ssid
    - signal strenght
    - if wep or wpa protection is activated
    - channel

    thank you,

    m.
     
    myspacee, Aug 14, 2008
    #1
    1. Advertising

  2. myspacee

    Pavel A. Guest

    myspacee wrote:
    > hello,
    > i've a request.
    >
    > with vbs script, Is possible to obtain info about wireless connection ?
    >
    > Need :
    > - ssid
    > - signal strenght
    > - if wep or wpa protection is activated
    > - channel


    Here's one short example.
    For more, please ask in scripting newsgroups or
    microsoft.public.platformsdk.networking.

    Regards,
    --PA


    ========= begin ===============
    'From: http://www.theludwigs.com/smithsandbox/vbscript/vbscript.htm
    ‘VBscript for 802.11 SSID and WMI
    ‘ it should report 802.11 access points in the vicinity.

    Set nicSet = _
    GetObject("winmgmts:{impersonationLevel=impersonate}!root/wmi")._
    InstancesOf("MSNdis_80211_ReceivedSignalStrength")

    For Each nic In nicSet
    ss = nic.Ndis80211ReceivedSignalStrength
    Next

    Set nicSet = _
    GetObject("winmgmts:{impersonationLevel=impersonate}!root/wmi")._
    InstancesOf("MSNdis_80211_BSSIList")

    For Each nic In nicSet
    obset = nic.Ndis80211BSSIList
    Next

    Text= ""

    For Each ob In obset
    ssidarr = ob.Ndis80211SsId
    RSSI = ob.Ndis80211Rssi
    SSID = ""

    For t = 0 To 31
    If ssidarr(t) > 13 Then
    SSID = SSID + Chr(ssidarr(t))
    End If
    Next

    Text = Text & SSID & " " & RSSI & " dBm" & vbCrLf
    Next

    MsgBox "The 802.11 Basestations are :" & vbcrlf & Text & vbcrlf
    '=========== end ======================
     
    Pavel A., Aug 14, 2008
    #2
    1. Advertising

  3. myspacee

    myspacee Guest

    little buggy class...

    scripts find often return garbage as ssid name.

    but Find nice one :

    '-----8<------------------------------------------------
    On Error Resume Next

    Const ForReading = 1
    Const ForWriting = 2
    Const ForAppending = 8

    Set fso = CreateObject("Scripting.FileSystemObject")

    Set Wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!root/wmi")

    While True

    set scan = wmi.Get("MSNDis_80211_BssIdListScan")
    set scanInst = scan.SpawnInstance_
    scanInst.InstanceName = "D-Link AirPlus XtremeG+ DWL-G650+ Wireless
    Cardbus Adapter"
    scanInst.Active = True
    scanInst.UnusedParameter = 0
    scanInst.Put_

    Set nicSet = Wmi.InstancesOf("MSNdis_80211_BSSIList")
    For Each nic In nicSet
    obset = nic.Ndis80211BSSIList
    Next

    Text= ""
    For Each ob In obset
    macAddr = ob.Ndis80211MacAddress
    RSSI = ob.Ndis80211Rssi
    macAddrStr = ""
    For t = 0 To 5
    macAddrStr = macAddrStr + Hex(macAddr(t))
    Next
    Text = Text & macAddrStr & " " & RSSI & " dBm" & vbCrLf
    next

    'msgbox "The 802.11 Basestations are :" & vbcrlf & Text & vbcrlf

    Set file = fso_OpenTextFile("wlan.txt", ForWriting, True)
    file.WriteLine(Text)
    file.Close()

    Set fileLog = fso_OpenTextFile("wlanlog.txt", ForAppending, True)
    fileLog.WriteLine("-" & Now & "-")
    fileLog.WriteLine(Text)
    fileLog.Close()

    WScript.Sleep 1000

    Wend
    '-------------------->8----------------------------------------



    can anyone add ssid name in log created ?


    Pavel thank you for reply, where can i found ?
    microsoft.public.platformsdk.networking

    thank you,

    m.


    "Pavel A." wrote:

    > myspacee wrote:
    > > hello,
    > > i've a request.
    > >
    > > with vbs script, Is possible to obtain info about wireless connection ?
    > >
    > > Need :
    > > - ssid
    > > - signal strenght
    > > - if wep or wpa protection is activated
    > > - channel

    >
    > Here's one short example.
    > For more, please ask in scripting newsgroups or
    > microsoft.public.platformsdk.networking.
    >
    > Regards,
    > --PA
    >
    >
    > ========= begin ===============
    > 'From: http://www.theludwigs.com/smithsandbox/vbscript/vbscript.htm
    > ‘VBscript for 802.11 SSID and WMI
    > ‘ it should report 802.11 access points in the vicinity.
    >
    > Set nicSet = _
    > GetObject("winmgmts:{impersonationLevel=impersonate}!root/wmi")._
    > InstancesOf("MSNdis_80211_ReceivedSignalStrength")
    >
    > For Each nic In nicSet
    > ss = nic.Ndis80211ReceivedSignalStrength
    > Next
    >
    > Set nicSet = _
    > GetObject("winmgmts:{impersonationLevel=impersonate}!root/wmi")._
    > InstancesOf("MSNdis_80211_BSSIList")
    >
    > For Each nic In nicSet
    > obset = nic.Ndis80211BSSIList
    > Next
    >
    > Text= ""
    >
    > For Each ob In obset
    > ssidarr = ob.Ndis80211SsId
    > RSSI = ob.Ndis80211Rssi
    > SSID = ""
    >
    > For t = 0 To 31
    > If ssidarr(t) > 13 Then
    > SSID = SSID + Chr(ssidarr(t))
    > End If
    > Next
    >
    > Text = Text & SSID & " " & RSSI & " dBm" & vbCrLf
    > Next
    >
    > MsgBox "The 802.11 Basestations are :" & vbcrlf & Text & vbcrlf
    > '=========== end ======================
    >
     
    myspacee, Aug 14, 2008
    #3
  4. myspacee

    Pavel A. Guest

    myspacee wrote:
    > little buggy class...
    >
    > scripts find often return garbage as ssid name.


    This is because there are two structures for SSID name:
    the old one (NDIS_WLAN_BSSID) has fixed size, it
    is what WMI uses on WinXP.
    The new struct, NDIS_WLAN_BSSID_EX, has variable size
    (so you can't simply make array of these) and it breaks
    the older WMI classes.
    All modern wi-fi drivers return only new structs.

    --PA
     
    Pavel A., Aug 14, 2008
    #4
  5. myspacee

    myspacee Guest

    modify script to obtain also SSID

    '------------------8<-------------------------------------------------
    ' VBScript source code
    On Error Resume Next

    Set fso = CreateObject("Scripting.FileSystemObject")

    Set Wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!root/wmi")

    set scan = wmi.Get("MSNDis_80211_BssIdListScan")
    set scanInst = scan.SpawnInstance_
    scanInst.Active = True
    scanInst.UnusedParameter = 0
    scanInst.Put_

    Set nicSet = Wmi.InstancesOf("MSNdis_80211_BSSIList")


    For Each nic In nicSet
    obset = nic.Ndis80211BSSIList


    Text= ""

    '------------------------------------------ MAC
    For Each ob In obset
    macAddr = ob.Ndis80211MacAddress
    RSSI = ob.Ndis80211Rssi
    macAddrStr = ""
    For t = 0 To 5
    macAddrStr = macAddrStr + Hex(macAddr(t)) + "."
    Next


    '------------------------------------------ SSID
    ssidarr = ob.Ndis80211SsId
    SSID = ""
    set objSWbemServices = GetObject("winmgmts:\\.\root\wmi")
    set colInstances = objSwbemServices.ExecQuery("SELECT * FROM
    MSNdis_80211_BSSIList")

    for each obj in colInstances
    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
    next
    next
    Next


    wscript.echo SSID & " " & Text & "MAC:" & macAddrStr & " RSSI:" & RSSI &
    " dBm" & vbCrLf
    Text = SSID & " " & Text & "MAC:" & macAddrStr & " RSSI:" & RSSI & " dBm"
    & vbCrLf
    next

    Set file = fso_OpenTextFile("wlan.txt", 2, True)
    file.WriteLine(Text)
    file.Close(
    ---------------------->8-------------------------------------------------------


    miss info about encription (wep, Wpa) and used channel...

    anyone want to help ? :)


    m.
     
    myspacee, Aug 14, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    0
    Views:
    2,146
  2. =?Utf-8?B?SGVpbkQ=?=

    Wireless DHCP clients cannot obtain an IP address from the DHCP se

    =?Utf-8?B?SGVpbkQ=?=, Jan 8, 2006, in forum: Wireless Networking
    Replies:
    0
    Views:
    2,848
    =?Utf-8?B?SGVpbkQ=?=
    Jan 8, 2006
  3. PeterPan

    Wanted Info on UK-Info, & WebDesign

    PeterPan, Nov 27, 2003, in forum: Computer Support
    Replies:
    3
    Views:
    776
  4. =?Utf-8?B?UmFsZiBCLiBMdWtuZXI=?=

    Wireless Network Connection Unable to obtain IP

    =?Utf-8?B?UmFsZiBCLiBMdWtuZXI=?=, Jul 24, 2006, in forum: Wireless Networking
    Replies:
    8
    Views:
    14,914
    =?Utf-8?B?UmFsZiBCLiBMdWtuZXI=?=
    Aug 17, 2006
  5. I am I

    Wireless connection...please help w/ info

    I am I, Feb 9, 2006, in forum: Computer Information
    Replies:
    4
    Views:
    458
    Duane Arnold
    Feb 10, 2006
Loading...

Share This Page