Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WMI using QTP
#1
Not Solved
Hey,

Im trying to work with WMI on QTP. I wish to get and set values of an SNMP device. I am able to get any value i want but am having problems with setting values of parameters of the SNMP device.

MSDN provides the following example for writing to an SNMP device.

Code:
Set objLocator = CreateObject("wbemscripting.swbemlocator")
Set objServices = objLocator.ConnectServer(, "root\snmp\mngd_hub")
objServices.security_.privileges.AddAsString("SeSecurityPrivilege")
Set obj= objServices.Get("SNMP_NET_DEVICE_123=@")
obj.deviceLocation = "40/5073"
obj.put_

I am having problems with the obj.put_ line. my code is as follows.


Code:
strTargetSnmpDevice = "137.237.178.160"
strTargetSnmpCommunity = "public"

set objWmiLocator  = CreateObject("WbemScripting.SWbemLocator")
set objWmiServices = objWmiLocator.ConnectServer("", "root\snmp\localhost")

set objWmiNamedValueSet  = CreateObject("WbemScripting.SWbemNamedValueSet")
objWmiNamedValueSet.Add "AgentAddress", strTargetSnmpDevice
objWmiNamedValueSet.Add "AgentReadCommunityName", strTargetSnmpCommunity
objWmiNamedValueSet.Add "Correlate", FALSE, 0
objWmiServices.security_.privileges.AddAsString("SeSecurityPrivilege")

set colSystem = objWmiServices.InstancesOf("SNMP_DELTA_parameterTable", , objWmiNamedValueSet)
For Each objSystem In colSystem
'Getting Value
msgbox "Value="&objSystem.parameterRate
'Setting value
objSystem.parameterRate="3200000"
objSystem.put_ !!!!!!!!!!!PROBLEM!!!!!!!!!!!!!!
Next
The error I am getting is "Invalid Class" for objSystem. What is wrong!!??!

Please do help me out as this is urgent!

Thanks in advance!!

Arjun
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)