Adapter



With Adapter object you can access to it's properties. All properties is read only.

 

Example:

 

'netcom.dll contains 'NetCom.Remote' object.

Set Remote = CreateObject("NetCom.Remote")

 

With Remote

       .Host = "192.168.0.1"

       .Port = 42566

       .UserName = "Administrator"

       .Password = "mypass"

       'Connect and query remote TrafficFilter object

       Set TrafficFilter = .CreateRoot

End With

 

'Check interfaces count

WScript.Echo "Interfaces count: " & TrafficFilter.Adapters.Count

If (TrafficFilter.Adapters.Count = 0) Then

       WScript.Echo "Network interfaces not detected"

       Set TrafficFilter = Nothing

       Remote.Disconnect

       Set Remote = Nothing

       WScript.Echo vbCrLf & "Press any key..."

       WScript.StdIn.Read(1)

       WScript.Quit

End If

 

'Find needed interface

WScript.Echo "Find 'DSL' interface..."

InterfaceDeviceName = ""

With TrafficFilter.Adapters

       For I = 0 To .Count - 1

               Set Intf = .Items(I)

               If (Intf.Name = "DSL") And (Intf.IsFilterStarted) Then

                       InterfaceDeviceName = Intf.DeviceName

                       Exit For

               End If

       Next

End With

 

If InterfaceDeviceName = "" Then

       WScript.Echo "Network interface with name 'DSL' not found or filtering on this interface not enabled"

       Set TrafficFilter = Nothing

       Remote.Disconnect

       Set Remote = Nothing

       WScript.Echo vbCrLf & "Press any key..."

       WScript.StdIn.Read(1)

       WScript.Quit

End If

 

Set Rules = TrafficFilter.Rules

With Rules

       'Add new rule as first in list

       .Insert 0, "MyRule"

       'Find new added rule

       Set Rule = .FindByName("MyRule")

       With Rule

               .Enabled = False

               'Deny packets

               .Action = 2

               'Add found InterfaceDeviceName

               .ConditionInterfaces.Add InterfaceDeviceName

               'In range of ConditionInterfaces

               .ConditionInterfacesOperator = 1

 

               .Enabled = True

       End With

 

       'Force configuration saving (normally configuration saved every 3 minutes automatically)

       TrafficFilter.ForceSaveConfig

 

       WScript.Echo "Added new rule with name " & Rule.Name

End With

 

Set Rule = Nothing

Set Rules = Nothing

Set TrafficFilter = Nothing

Remote.Disconnect

Set Remote = Nothing

WScript.Echo vbCrLf & "Press any key..."

WScript.StdIn.Read(1)