Software metering uses rules on the SMS site server to determine which files are metered on client computers. It is possible to programmatically create a rule by creating an instance of SMS_MeteredProductRule on the SMS site server. The following properties of SMS_MeteredProductRule must be provided:

The Comment property is optional. OriginalFileName can be used instead of FileName, both can be supplied, or FileName only can be supplied. No other properties should be supplied.

To create a software metering rule, you need the Meter right for the site specified site code, and you need the Create right for software metering rules. Administer rights are not required. For more information, see the SMS 2003 Concepts, Planning, and Deployment Guide. For additional information about creating software metering rules, see the SMS 2003 SDK.

The following script creates a software metering rule.


Dim objSWbemLocator
Dim objSWbemServices
Dim objNewSWbemObject
Dim objSWbemObject
Dim ProviderLoc
Dim Location
Dim strClass
Dim strSiteCode

set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")

set objSWbemServices= objSWbemLocator.ConnectServer _
	(".", "root\sms")

Set ProviderLoc = objSWbemServices.InstancesOf("SMS_ProviderLocation")

For Each Location In ProviderLoc
		If Location.ProviderForLocalSite = True Then
			Set objSWbemServices = objSWbemLocator.ConnectServer _
				 (Location.Machine, "root\sms\site_" + Location.SiteCode)
		End If

Set objSWbemObject = objSWbemServices.Get(strClass)
Set objNewSWbemObject = objSWbemObject.SpawnInstance_()

objNewSWbemObject.Properties_.Item("ProductName")="Character Mapper"
objNewSWbemObject.Properties_.Item("SiteCode")= strSiteCode


Compiling the Code

  • Requires Windows 2000 Server SP2 or later.

  • Requires an SMS 2003 Site Server.

See Also