0 Replies Latest reply on Mar 26, 2015 6:28 AM by Landon Winburn

    Get HW Address of the Connected AP

    Landon Winburn Expert
      This code will set an environment variable called BBSID that you can use environment variable conditions with to detect which wireless access point you are connected to. This is useful for detecting where a laptop might be for location based printing and such.

      Set WshShell = WScript.CreateObject("WScript.Shell")
      Set oUserEnv = WshShell.Environment("USER")
      Set oExec = WshShell.Exec("netsh wlan show interfaces") 
      Output = oExec.StdOut.ReadAll
      If Instr(Output, "    State                  : disconnected") > 0 Then
       'Msgbox "Disconnected"
       oUserEnv("BSSID") = "Disconnected"
      Else
       Lines = Split(Output, vbcrlf)
       For Each Line in Lines
        If Instr(Line, "BSSID") > 0 Then
         'Msgbox Trim(Mid(Line, Instr(line, ":") +1 ))
         oUserEnv("BSSID") = Trim(Mid(Line, Instr(line, ":") +1 ))
        End If
       Next
      End If