SMS脚本节选四:创建,修改,删除SMS对象

The processes by which SMS objects are managed can be divided into the following categories:

  • Creating an SMS object

  • Modifying an SMS object

  • Deleting an SMS object

  • Calling a method on an SMS object

For more information on creating and deleting WMI objects, see the <linktext xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></linktext>WMI SDK.

To create an SMS object

  1. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Connect to an SMS Provider, and get the SWbemServices object.

  2. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Create an instance of an SMS object by using the <linktext xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></linktext>SpawnInstance method supported by the desired class. For example, to create an instance of a package object (SMS_Package), use the following code:

  3. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Populate the required properties. For example, the following code sets the properties for a package:

  4. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Save the SMS object by using the <linktext xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></linktext>Put_ method supported by the SMS object class. For example, the following line of code puts or saves a package:

To modify an SMS object

  1. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Get the instance of the required SMS object by using the Windows Script Host GetObject method and supplying the path to the required object. For example, to get an instance of an advertisement object (SMS_Advertisement) identified as 99920002, use the following code.

  2. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Set the required properties of the SMS object. To enable the assigned schedule for an advertisement object, set the AssignedScheduledEnabled property to True, as in the following example:

  3. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Update the SMS object by using the SMS object class Put method. For example, to update the advertisement opened in step 1, use the following code:

To delete an SMS object

  1. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Get the instance of the required SMS object by using GetObject and supplying the path to the required object. For example, to get an instance of an advertisement object (SMS_Advertisement) identified as 99920003, use the following code:

  2. <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></content>

    Delete the SMS object instance by using the SMS object class <linktext xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"></linktext>Delete_ method. For example, to delete the advertisement object opened in step 1, use the following code:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值