Freigeben über


Running All Available Programs on an SMS 2003 Advanced Client

Recently a customer complained that you can't run more than one advertised program at a time on a client, but they could in SMS 2.0. Here is an example VBScript that runs all available advertised programs on a client.

 'rslaten 10/10/2007
'Example of how to run all available programs
'If you want to select some programs, but not all, then use C# or VB.NET to build a simple UI
'or accept parameters into this script to only run certain programs

Set UI = CreateObject("UIResource.UIResourceMgr")
Set ads = UI.GetAvailableApplications
For each o in ads
    WScript.Echo "DEBUG: Program = " & o.Name
    lastRunTime = o.LastRunTime
    bIsMandatoryProgramPending = UI.IsMandatoryProgramPending
    While bIsMandatoryProgramPending
        WScript.Sleep(10000)
        bIsMandatoryProgramPending = UI.IsMandatoryProgramPending
        WScript.Echo "DEBUG: Program is running, sleeping"
    WEnd
    WScript.Echo "DEBUG: Running program: " & o.Name
    UI.ExecuteProgram o.ID, o.PackageID, True
    bProgramComplete = false
    While Not bProgramComplete
        WScript.Echo "DEBUG: Checking if " & o.Name & " has completed running..."
        WScript.Sleep(10000)
        Set p = UI.GetProgram(o.ID, o.PackageID)
        If p.LastRunTime <> o.LastRunTime Then
            WScript.Echo "DEBUG: " & o.Name & " has completed running..."
            bProgramComplete = true
        End If
    WEnd
Next

Comments