VbsEdit, the award-winning VBScript editor that dramatically reduces the time you spend writing .VBS scripts

Sample scripts


SMS 2003
   SMS 2003 Site Server
       Update a Package

' Update a Package



On Error Resume Next

Dim objSWbemLocator
Dim objSWbemServices
Dim ProviderLoc
Dim Location
Dim PackageID
Dim colPackages
Dim Package

'Enter the package ID of the package to be updated
PackageID = "PACKAGEID"

'To connect to the local SMS site's Provider by using SWbemLocator
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
Next

'To find the package ID in the SMS_Packages class and use the RefreshPkgSource Method to initiate update.
Set colPackages = objSWbemServices.ExecQuery _
  ("Select * from SMS_Package where PackageID = '" & PackageID & "'"

If colPackages.count <;>0 Then
  For Each Package In colPackages
    Package.RefreshPkgSource( )
    WScript.Echo "Package '" & PackageID & "' Updated!"
  Next
Else
   WScript.Echo "Package '" & PackageID & "' Not Found!"
End If



VbsEdit includes all these samples!




Download Now!

Version 5.4.1 - This package includes VbsEdit 32-bit, VbsEdit 64-bit, HtaEdit 32-bit and HtaEdit 64-bit.
The evaluation version never expires.



Home   Buy Now   HtaEdit   Support   Video   What's new ?  

Copyright (C) 2001-2012 Adersoft