I have found a vbs/wmi script that works, it find the bssid of the acesspoint the client is currently connected to.
I want to use this in kix, my problem is to isolate the mac value the bssid returns to further use in kix!
I have made a call to this vbs script from kix but i can not return the bssid value that is found here for use in kix.
I want to use it to locate the client an map the printer nearest, with use of a case command in kix.
But after calling this vbs script the bssid/mac get lost?


can anyone please help med with this problem, or maybe convert the vbs script to kix!?


Kind regards
roundup


 Code:
' edit strComputer, save to a dir, open up cmd shell, and type: cscript GETBSSID.vbs

filename = "GETBSSID.vbs"
version = "Version 1.0"
description = "Get BSSID of local XP machine's Wi-Fi card via WMI."
' cmd: GETBSSID.vbs 1 (where 1 here is the wifi_cardnr )


strComputer = "."
set objSWbemServices = GetObject("winmgmts:\\"& strComputer & "\root\wmi")

' wscript.echo description & vbcrlf & version & vbcrlf

' find adapters by querying for active signal
set colInstances = objSwbemServices.ExecQuery _
  ("SELECT * FROM MSNdis_80211_ReceivedSignalStrength WHERE Active = True")
if wscript.Arguments.Count = 0 Then ' spit out usage and cards if no args
    wscript.echo "Skriv: cscript " & filename & " [kortnr]"
   card_no=1
   for each objInstance in colInstances ' more than one instance per card may show up, btw
      wscript.echo card_no & " = " & objInstance.InstanceName
      card_no=card_no +1
   next
    wscript.quit
end If

' numberify the arg and set our adapter, matching command arg with an instancename
card_no=abs(wscript.Arguments(0))
x=1
for each objInstance in colInstances
   if x = card_no then
      wifiAdapter = objInstance.InstanceName
      x = x + 1
   end if
next
' wscript.echo "Using " & wifiAdapter & vbcrlf


last_signal = 0 ' we need to initialize this, but I'm not sure if -90 would be a better val to start with



' get bssid
bssid = ""
set colInstances = objSwbemServices.ExecQuery ("SELECT * FROM MSNdis_80211_BaseServiceSetIdentifier WHERE Active = True AND InstanceName ='" & wifiAdapter & "'")
for each objInstance in colInstances
   macbyte = 0
   ' convert decimals to hex.  pad zeros & slip in colons where needed
   for each decval in objInstance.Ndis80211MacAddress
      if decval<17 then
         bssid = bssid & "0"
      end if
      bssid = bssid & Hex(decval)
      if macbyte < 5 then
         bssid = bssid & ":"
         macbyte = macbyte + 1
      end if
   next
next

' get ssid
' ssid = ""
' set colInstances = objSwbemServices.ExecQuery _
'  ("SELECT * FROM MSNdis_80211_ServiceSetIdentifier WHERE Active = True AND InstanceName ='" & wifiAdapter & "'")
' for each objInstance in colInstances
   ' convert decimals to chars and avoid non-alphanumerics
'   for each decval in objInstance.Ndis80211SsId
'      if (decval > 31 AND decval < 127) then
'         ssid = ssid & Chr(decval)
'      end if
'   next
' next

' this could be tricky, as I've read signal strength is reported in different ways per card.  YMMV.
set colInstances = objSwbemServices.ExecQuery _
  ("SELECT * FROM MSNdis_80211_ReceivedSignalStrength WHERE Active = True AND InstanceName ='" & wifiAdapter & "'")
for each objInstance in colInstances
         sigraw = objInstance.Ndis80211ReceivedSignalStrength ' raw number for later comparison
         signal = sigraw & "dB" ' make it a string that says dB
next

last_signal = sigraw
' Wscript.echo "BSSID: " & bssid & "  SSID: " & ssid & "  RSSI: " & signal
Wscript.echo "BSSID: " & bssid


Edited by Mart (2010-10-29 01:47 PM)
Edit Reason: Please use code tags when posting code.