0 Replies Latest reply on Mar 23, 2016 9:27 AM by Landon Winburn

    Detecting network information for use with network conditions

    Landon Winburn Expert
      I didn't see where I posted this previously so here you go... You can use this custom action in a network connect or disconnect trigger to list out the information needed for the network conditions within those triggers. It will write a file to c:\temp named the adapter name when the trigger is fired and list all the information within it.

      Set Fso = CreateObject("Scripting.FileSystemObject")
      Set F = Fso.OpenTextFile("c:\temp\" & GetEMSessionVariable("Network.Adapter.FriendlyName") & ".txt", 2, True)
      F.Writeline "Network.Adapter.FriendlyName: " & GetEMSessionVariable("Network.Adapter.FriendlyName")
      F.Writeline "Network.Adapter.Description: " & GetEMSessionVariable("Network.Adapter.Description")
      F.Writeline "Network.Adapter.Id: " & GetEMSessionVariable("Network.Adapter.Id")
      F.Writeline "Network.Adapter.IsVirtual: " & GetEMSessionVariable("Network.Adapter.IsVirtual")
      F.Writeline "Network.Adapter.IsWireless: " & GetEMSessionVariable("Network.Adapter.IsWireless")
      F.Writeline "Network.Domain: " & GetEMSessionVariable("Network.Domain")
      F.Writeline "Network.DomainType: " & GetEMSessionVariable("Network.DomainType")
      F.Writeline "Network.Id: " & GetEMSessionVariable("Network.Id")
      F.Writeline "Network.Adapter.BSSID: " & GetEMSessionVariable("Network.Adapter.BSSID")
      'EM Auto Generated Start
      'This code was automatically inserted and should NOT be modified
      Function CreateTriggerContextVariableName(sessionVariableName)
                      Set WshShell = WScript.CreateObject("WScript.Shell")
                      Set WshProccessEnv = WshShell.Environment("Process")
                      Dim sessVar
                      Dim triggerContextId 
                      triggerContextId = WshProccessEnv("TRIGGERCONTEXTID")
                      if triggerContextId <> "" then
                                      sessVar =  triggerContextId & "." & sessionVariableName
                                      sessVar =  sessionVariableName
                      end if
                      CreateTriggerContextVariableName = sessVar
      End Function
      Dim sessionVariableReader
      Function GetEMSessionVariable(name)
          GetEMSessionVariable = ""
          If (IsEmpty(sessionVariableReader)) Then
              Set sessionVariableReader = CreateObject("EMValue.EMGetValue")
          end if
          sessionVariableReader.Name = CreateTriggerContextVariableName(name)
          Dim errorCode
          errorCode = sessionVariableReader.Apply("")
          If errorCode = 0 Then
              GetEMSessionVariable = sessionVariableReader.Value
          end if        
      End Function
      'EM Auto Generated End