Run Program from VBS!

The code for the VBS on the MSDN site was wrong.

Here is the working code:

———————————————————————–

Call RunProgram (“ProgramID”,”PackageID”)

Sub RunProgram(programId, packageId)
On Error Resume Next
Dim oUIResource
Dim oPrograms
Dim oProgram

Set oUIResource = CreateObject (“UIResource.UIResourceMgr”)
If oUIResource Is Nothing Then
wscript.echo “Could not create Resource Object – quitting”
Exit Sub
End If
if oUIResource.IsMandatoryProgramPending = 1 Then
Wscript.Echo “Mandatory program pending. Try again later.”
Set oUIResource=Nothing
Exit Sub
End If
Set oProgram = oUIResource.GetProgram(programId,packageId)
if oProgram is Nothing Then
WScript.Echo “Couldn’t get the program”
Set oUIResource=Nothing
Exit Sub
End If
Wscript.Echo “Running program: ” & oProgram.FullName
oUIResource.ExecuteProgram programId, packageID, true
Set oProgram=Nothing
Set oUIResource=Nothing
End Sub
—————————————————————
The ProgramID is the name of the program that should run (ie: the name you give to the program in the package). You can easily get it by running that query in SQL Manager on your database: select * from pkgprograms where pkgID = ‘nn’ where nn is your PackageID.

The script is now running fine on my side and Microsoft will correct the script posted on the MSDN website as soon as they can.

From:

http://social.technet.microsoft.com/Forums/en/configmgrswdist/thread/e30694ec-cceb-40d2-a370-1dd2aed87a92

Good To Know: http://msdn.microsoft.com/en-us/library/cc143667.aspx

Leave a comment

Your comment