hey all,

having some trouble with a COM script that I am converting from VBS to Kix. We are using COM to grab available SMS packages from their client machines and then install them in a certain order. I am currently trying to install 1 package as a test but the ExecuteProgram command keeps failing with a syntax error. I have tried every possible syntax I can think of. Can anyone help???

Kix Code:
 Code:
Dim $oUIResource 
Dim $oPrograms 
Dim $oProgram 

$oUIResource = CreateObject("UIResource.UIResourceMgr")

;check if resource was created
If $oUIResource = ""
	MessageBox("Could not create Resource Object Quitting", "No Resource Object", 16)
	Quit
EndIf

;Check for mandatory pending package
If $oUIResourceMgr.IsMandatoryProgramPending = 1 
	$null = MessageBox("Mandatory program pending. Try again later.", "Mandatory Program Pending", 16)
	$oUIResource = Nothing
	Quit
EndIf



;Get List of Available apps
$oPrograms = $oUIResource.GetAvailableApplications

;Check if Available apps is created
If $oPrograms = ""
	MessageBox("Failed to get programs object - quitting", "No Programs Object", 16)
   $oUIResource = ""
EndIf 

;Display number of programs
$numprog = $oPrograms.Count
MessageBox("$numprog", "Success...Program Amount", 16)



;Show all Programs and program names
For Each $oProgram in $oPrograms
	$fullnameprog = $oProgram.FullName
	$packidprog = $oProgram.PackageId
	$null=MessageBox("$fullnameprog", "Full Name of Package", 16)
	$null=MessageBox("$packidprog", "Package ID", 16)
		
	If $oProgram = ""
		$null = MessageBox("Couldn't get the program", "Fail", 16)
		$oUIResource = ""
		Quit
	Else
		If $packidprog = "CEN0172C"
		   $null = MessageBox("$fullnameprog", "Running Program", 16)
			$test = $oUIResource.ExecuteProgram ($fullnameprog,$packidprog)
			$null = MessageBox("$test", "Result", 16)
		Else
			$null = MessageBox("$packidprog", "Different Package ID", 16)
		EndIf		 
		$oProgram = ""
		$oUIResource = ""
	EndIf
	
Next 
		
$oProgram = ""
$oUIResource = ""
Quit


Sample VBS Code
 Code:
if oUIResourceMgr.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 
 
    Set oProgram=Nothing
    Set oUIResource=Nothing

Associated COM articles from Microsoft:

http://msdn.microsoft.com/en-us/library/cc143667.aspx
http://msdn.microsoft.com/en-us/library/cc143231.aspx


It fails at this line every time with a syntax error:

$test = $oUIResource.ExecuteProgram ($fullnameprog,$packidprog)


Thanks again, any help is appreciated!!


Edited by Allen (2010-09-16 10:19 PM)
Edit Reason: added code tags