Good afternoon All.
wondered if anyone could point me in the right direction?
1. have a .mof file of:
#pragma namespace("\\\\.\\Root\\Cimv2")
class MyClass_MachineProperties
{
string VMClusterName;
string VMHostName;
string Region;
string Version;
};
I import this and i can view my new class and its properties through:
strComputer = "."
strNameSpace = "root\cimv2"
strClass = "MyClass_MachineProperties"
Set objClass = GetObject("winmgmts:\\" & strComputer & _
"\" & strNameSpace & ":" & strClass)
WScript.Echo strClass & " Class Properties"
WScript.Echo "------------------------------"
For Each objClassProperty In objClass.Properties_
WScript.Echo objClassProperty.Name
Next
I now want to create an instance of this class through a vbscript and populate its properties with information...which is where i am a little stuck. have looked at Create methods but my class doesnt expose a create method explicitly??? any ideas? I found this post but the code doesnt work...
set NewObject = GetObject("winmgmts:root\cimv2").Get
NewObject.Path_.Class = "MyClass_MachineProperties"
NewObject.Properties_.Add "VMClusterName", "TestClusterName1"
wondered if anyone could point me in the right direction?
1. have a .mof file of:
#pragma namespace("\\\\.\\Root\\Cimv2")
class MyClass_MachineProperties
{
string VMClusterName;
string VMHostName;
string Region;
string Version;
};
I import this and i can view my new class and its properties through:
strComputer = "."
strNameSpace = "root\cimv2"
strClass = "MyClass_MachineProperties"
Set objClass = GetObject("winmgmts:\\" & strComputer & _
"\" & strNameSpace & ":" & strClass)
WScript.Echo strClass & " Class Properties"
WScript.Echo "------------------------------"
For Each objClassProperty In objClass.Properties_
WScript.Echo objClassProperty.Name
Next
I now want to create an instance of this class through a vbscript and populate its properties with information...which is where i am a little stuck. have looked at Create methods but my class doesnt expose a create method explicitly??? any ideas? I found this post but the code doesnt work...
set NewObject = GetObject("winmgmts:root\cimv2").Get
NewObject.Path_.Class = "MyClass_MachineProperties"
NewObject.Properties_.Add "VMClusterName", "TestClusterName1"