The documentation in .NET and MSDN indicat that before committing the changes the keys must be defined on the property but nowhere that i can find do they tell you how to add or define the key on the property.
Other than building a MOF file and running it through the MOFcompiler or Through wbemtest or such manually assigning the Key
I would appreciatesome assistance
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Jacques Pretorius" <JacquesP...@discussions.microsoft.com> wrote in
message news:DA4B5652-10C0-4011...@microsoft.com...
Dim sgetvalue As Integer
Dim firstval(3) As String
Dim secondval(3) As String
Dim c As New ManagementClass("root\cimv2", String.Empty, Nothing)
Dim options As New PutOptions
'Set the wmi update options
options.Type = PutType.CreateOnly
'Setup testing value array
firstval(0) = "test1"
secondval(0) = "val1"
firstval(1) = "test2"
secondval(1) = "val2"
firstval(2) = "test3"
secondval(2) = "val3"
c("__Class") = "demo"
Try
Dim i As Integer
Dim secondoval As New ManagementObject
Do Until i = firstval.Length - 1
c.Properties.Add(firstval(i), CimType.String, False)
i = i + 1
Loop
c.Put(options)
Catch e As ManagementException
MsgBox("Couldn't update class: " & e.Message)
End Try
Dim newInstance As New ManagementObject
Try
newInstance = c.CreateInstance()
newInstance("test1") = "mynewinstval1"
newInstance.Put() 'to commit the new instance.
Catch e As ManagementException
MsgBox("Couldn't update class: " & e.Message)
'MsgBox("Couldn't update class: " & e.ErrorInformation)
End Try
Dim sgetvalue As Integer
Dim firstval(3) As String
Dim secondval(3) As String
Dim c As New ManagementClass("root\cimv2", String.Empty, Nothing)
'Setup testing value array
firstval(0) = "test1"
secondval(0) = "val1"
firstval(1) = "test2"
secondval(1) = "val2"
firstval(2) = "test3"
secondval(2) = "val3"
c("__Class") = "demo"
Dim options As New PutOptions
'Set the wmi update options
options.Type = PutType.CreateOnly
Try
Dim i As Integer
Dim secondoval As New ManagementObject
Do Until i = firstval.Length - 1
c.Properties.Add(firstval(i), CimType.String, False)
i = i + 1
Loop
c.Put(options)
'Write the values to the WMI
Catch e As ManagementException
MsgBox("Couldn't update class: " & e.Message)
End Try
Dim newInstance As New ManagementObject
Try
newInstance = c.CreateInstance()
newInstance("test1") = "mynewinstval1"
newInstance.Put() 'to commit the new instance.
Catch e As ManagementException
MsgBox("Couldn't update class: " & e.Message)
'MsgBox("Couldn't update class: " & e.ErrorInformation)
End Try
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Jacques Pretorius" <JacquesP...@discussions.microsoft.com> wrote in
message news:1CAC2C6D-9BBE-4AD8...@microsoft.com...
Thanks