How to Add Properties to a Class

  1. Bind to the class in the IIS ADSI Schema you want to add a property to.
  2. Bind to the OptionalProperties list for the Class object.
  3. Add the new property to the list.
  4. Write the new OptionalProperties list to the metabase.

Example: Modify the OptionalProperties list for a Class object.

''''''''''''''''''''''''''''''''''
'   Get the parameters for the machine name.
Dim MachineName
Dim ClassName
Dim PropertyName
Dim Action
Dim ArgObj
Set ArgObj=WScript.Arguments
Action = ArgObj.Item (0)
MachineName = ArgObj.Item (1)
ClassName = ArgObj.Item (2)
PropertyName = ArgObj.Item (3)

'   Bind to Class in Schema container.
Dim SchemaObj
Dim NewClassObj
Set NewClassObj = GetObject ("IIS://" & MachineName & "/Schema/" & ClassName)

'   Set the OptionalProperties list.
'   Add PropertyName.
Dim OptPropList
Dim cnt
OptPropList = NewClassObj.OptionalProperties
cnt = UBound(OptProplist)
If (Action = "add") Then
   ReDim Preserve OptPropList(cnt+1)
   OptPropList(cnt+1) = PropertyName
   NewClassObj.OptionalProperties = OptPropList
End If

if (Action = "del") Then
   Dim temparraycount
   ReDim temparraycount (cnt-1)
   Dim tempcount1
   Dim tempcount2
   tempcount1 = 0
   tempcount2 = 0

   do while (tempcount2 <= cnt)
      If ( OptProplist(tempcount2) <> PropertyName) Then
         temparraycount (tempcount1) = OptPropList (tempcount2)
         tempcount1 = tempcount1 + 1
      End If
   tempcount2 = tempcount2 + 1
   Loop
   
   NewClassObj.OptionalProperties = temparraycount
End if

NewClassObj.SetInfo

For more examples see How to Create a Class and How to Create a Property.