VbsEdit, the award-winning VBScript editor that dramatically reduces the time you spend writing .VBS scripts

Sample scripts


Networking
   SNMP
       List SNMP MIB-II TCP and UDP Connections and Listening Ports

' List SNMP MIB-II TCP and UDP Connections and Listening Ports


strTargetSnmpDevice = "192.168.0.1"
 
Set objWmiLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWmiServices = objWmiLocator.ConnectServer("""root\snmp\localhost")
 
Set objWmiNamedValueSet = CreateObject("WbemScripting.SWbemNamedValueSet")
objWmiNamedValueSet.Add "AgentAddress", strTargetSnmpDevice
objWmiNamedValueSet.Add "AgentReadCommunityName""public"
 
Set colTcpConnTable = _
    objWmiServices.InstancesOf("SNMP_RFC1213_MIB_tcpConnTable", , _
        objWmiNamedValueSet)
 
Set colUdpTable = _
    objWmiServices.InstancesOf("SNMP_RFC1213_MIB_udpTable", , _
        objWmiNamedValueSet)
 
 
WScript.Echo "TCP Connections and Listening Ports" & vbCrLf & _
    "-----------------------------------"
 
For Each objTcpConn In colTcpConnTable
    WScript.Echo objTcpConn.tcpConnLocalAddress & ":"    & _
        objTcpConn.tcpConnLocalPort    & " => " & _
            objTcpConn.tcpConnRemAddress   & ":"    & _
                objTcpConn.tcpConnRemPort      & " "    & _
                    "[State: " & objTcpConn.tcpConnState & "]"
Next
 
WScript.Echo vbCrLf & "UDP Ports" & vbCrLf & "---------"
 
For Each objUdp In colUdpTable
    WScript.Echo objUdp.udpLocalAddress & ":" & objUdp.UdpLocalPort
Next



VbsEdit includes all these samples!




Download Now!

Version 5.4.1 - This package includes VbsEdit 32-bit, VbsEdit 64-bit, HtaEdit 32-bit and HtaEdit 64-bit.
The evaluation version never expires.



Home   Buy Now   HtaEdit   Support   Video   What's new ?  

Copyright (C) 2001-2012 Adersoft