Micro Focus QTP (UFT) Forums
WMI using QTP - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: WMI using QTP (/Thread-WMI-using-QTP)



WMI using QTP - aj_r - 07-23-2010

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