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:
- ProductName
- FileName
- OriginalFileName
- FileVersion
- LanguageID
- SiteCode
- ApplyToChildSites
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.
Example
Dim objSWbemLocator Dim objSWbemServices Dim objNewSWbemObject Dim objSWbemObject Dim ProviderLoc Dim Location Dim strClass Dim strSiteCode strClass="SMS_MeteredProductRule" 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) strSiteCode=Location.SiteCode End If Next Set objSWbemObject = objSWbemServices.Get(strClass) Set objNewSWbemObject = objSWbemObject.SpawnInstance_() objNewSWbemObject.Properties_.Item("ProductName")="Character Mapper" objNewSWbemObject.Properties_.Item("FileName")="charmap.exe" objNewSWbemObject.Properties_.Item("OriginalFileName")="charmap.exe" objNewSWbemObject.Properties_.Item("FileVersion")="*" objNewSWbemObject.Properties_.Item("LanguageID")="1033" objNewSWbemObject.Properties_.Item("SiteCode")= strSiteCode objNewSWbemObject.Properties_.Item("ApplyToChildSites")="true" objNewSWbemObject.Put_ |
Compiling the Code
- Requires Windows 2000 Server SP2 or later.
- Requires an SMS 2003 Site Server.