I have a command prompt utility called Net-SNMP that allows me to communicate with devices via SNMP.
Since there are quite a few devices I've tried to streamline the process by running the command prompt command from VBA.
The following function is something I pieced together.
The main problem I am having is that each execution of this function opens up a command prompt window. A secondary problem I'm having is when a SNMP connection can't be made the command prompt command waits about 10 seconds before it times-out. I want to be able for this function to run without any window popping up and also if there is no response from the command prompt for 1-2 seconds I want it to give up.
I did look in to the .run method to execute commands but I wasn't sure how to pass the return back in to VBA using this.
Looking for any solutions to get the job done.
Cheers!
Since there are quite a few devices I've tried to streamline the process by running the command prompt command from VBA.
The following function is something I pieced together.
Code:
Function GetSNMP(IP As String, OID As String, Optional Community As String)
If Community = Empty Then
Community = "public"
End If
Set S = CreateObject("wscript.shell")
ComString = "snmpget -v 2c -c " & Community & " " & IP & " " & OID
Set S = S.Exec(ComString)
GetSNMP = S.StdOut.ReadAll
End Function
The main problem I am having is that each execution of this function opens up a command prompt window. A secondary problem I'm having is when a SNMP connection can't be made the command prompt command waits about 10 seconds before it times-out. I want to be able for this function to run without any window popping up and also if there is no response from the command prompt for 1-2 seconds I want it to give up.
I did look in to the .run method to execute commands but I wasn't sure how to pass the return back in to VBA using this.
Looking for any solutions to get the job done.
Cheers!