Page 1 of 1 1
Topic Options
#199976 - 2010-09-20 08:11 PM VBS to Kix question
sliver16 Offline
Fresh Scripter

Registered: 2007-12-10
Posts: 10
Hi All,

I am converting the attached .vbs code into .kix and I am running into an issue. Everything seems to work perfectly fine except for one COM command.

This command in .VBS works fine:

oUIResource.ExecuteProgram sProgramID, sPackageID, TRUE

and in KIX throws up an error (Error:Unexpected Command):

$oUIResource.ExecuteProgram $sProgramID, $sPackageID, TRUE

I will include the test code of both below. Also...was wondering if anyone knew how to 'Shell' the COM command above. By 'Shell' I mean wait till the installation is finished and then continue the code and go onto the next application. Any help is greatly appreciated!!!



.VBS Code (works fine)
 Code:
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"
    End If

    Set oPrograms = oUIResource.GetAvailableApplications

    If oPrograms Is Nothing Then
        WScript.echo "Failed to get programs object - quitting"
        Set oUIResource=Nothing
    End If

    WScript.echo "There are " & oPrograms.Count & " programs"


    For Each oProgram In oPrograms
        WScript.Echo "Program Name: " & oProgram.FullName
        WScript.Echo "  Package ID: " & oProgram.PackageId
        WScript.Echo "  Prog ID: " & oProgram.Id

        sPackageName = oProgram.FullName 
        sPackageID = oProgram.PackageId 
        sProgramID = oProgram.Id

 			  
	Set myProgram = oUIResource.GetProgram(sprogramId, spackageId)
	oldTime = myProgram.LastRunTime
	WScript.Echo oldTime
    
   oUIResource.ExecuteProgram sProgramID, sPackageID, TRUE
    Next 

.KIX Code

$oUIResource = CreateObject("UIResource.UIResourceMgr")

If $oUIResource = ""
	MessageBox("Error Creating the OUIResource", "Error Creating UI", 16)
	Quit
EndIf
	
$oPrograms = $oUIResource.GetAvailableApplications
	
If $oPrograms = "" 
  MessageBox("Failed to get programs object - quitting", "Error Creating Programs Object", 16)
	$oUIResource = Nothing
	Quit
EndIf
		
For Each $oProgram in $oPrograms
		
	$sPackageName = $oProgram.FullName 
	$sPackageID = $oProgram.PackageId 
	$sProgramID = $oProgram.Id
	
	? "Package name: " + $sPackageName
	? "Package ID: " + $sPackageID
	? "Program ID: " + $sProgramID
								  
			$myProgram = $oUIResource.GetProgram($oProgram.Id, $oProgram.PackageId)
			$oldTime = $myProgram.LastRunTime
	      ? "Last Run Time: " + $oldTime
				       
	$oUIResource.ExecuteProgram $sProgramID, $sPackageID, TRUE	
			
Next 

Quit



Thanks alot for all your help in advance!!


Edited by Mart (2010-09-21 10:19 AM)
Edit Reason: Please use code tags when posting code.

Top
#199977 - 2010-09-20 08:33 PM Re: VBS to Kix question [Re: sliver16]
sliver16 Offline
Fresh Scripter

Registered: 2007-12-10
Posts: 10
Also wanted to note that the sProgramID contains dashes in it.

Ex-

sProgramID- XL-GBL-R1-016842-in
sPackageID- CENxxxx

Top
#199978 - 2010-09-20 08:51 PM Re: VBS to Kix question [Re: sliver16]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Try:
 Code:
$oUIResource.ExecuteProgram($sProgramID, $sPackageID, Not 0)

Top
#199979 - 2010-09-20 09:04 PM Re: VBS to Kix question [Re: Richard H.]
sliver16 Offline
Fresh Scripter

Registered: 2007-12-10
Posts: 10
amazing...that worked!! Thanks so much!! Been messing around with this for 2 days..lol. Any thoughts on the question about the installation waiting to be finished before moving on to the next one??

'Also...was wondering if anyone knew how to 'Shell' the COM command above. By 'Shell' I mean wait till the installation is finished and then continue the code and go onto the next application. Any help is greatly appreciated!!!'

Thanks again!!

Top
#200090 - 2010-09-28 04:54 PM Re: VBS to Kix question [Re: sliver16]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
"shell" usually waits, "run" kicks off a seperate pid and continues, to be certain, look in the reference-guide \:\) (I'm to dusty to remember my own name sometimes..).
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1045 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.054 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org