Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] Third Party Tools
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 09-09-2003, 06:30 AM
a_t_jackson a_t_jackson is online now
Registered User
 
Join Date: 03-11-2003
Location: Belfast, Northern Ireland
Posts: 23
How to get exit code from CABARC.EXE?

I'm using CABARC.EXE to package an ActiveX control into a CAB file. I've created a "Run Program" action in Vis Build and have been able to get it working properly with this syntax:

%DOSCMD% cabarc -s 6144 n MyApp.cab MyApp.inf MyApp.ocx

However, I also want to handle cases where something goes wrong. For example, if the file "MyApp.inf" doesn't exist the console window will actually show:

FCIAddFile() failed: code 1 [Failure opening file to be stored in cabinet]

but Vis Build doesn't pick up the error and reports that the action completed successfully. I've got "Success exit Codes = 0". Any ideas?
Reply With Quote
  #2  
Old 09-09-2003, 07:21 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Unfortunately, cabarc.exe doesn't return a non-zero exitcode in most error situations. You would need to parse the program output for error strings and fail the build if any are found. Here is one way it could be done (you can copy and paste the text below into VisBuildPro; it assumes VBScript is set as your default script language; the script code is accessed within VBP by clicking the Script Editor button within the step properties dialog and switching to the Step tab):


<step action='Run Program' type='0'>
<command>cabarc -s 6144 n %TEMP%\MyApp.cab c:\nonexist.ini</command>
<name>call cabarc</name>
<outputfrom type='3'>1</outputfrom>
<script><![CDATA[
Function vbld_StepDone()
' look for the string ' failed' in the cabarc output and fail the build if found
If InStr(Application.Macros(vbldMacroSystem)("LASTSTE P_OUTPUT"), " failed") <> 0 Then _
Err.Raise 1, Step.Name, "cabarc utility failed"
End Function
]]></script>
</step>
Reply With Quote
  #3  
Old 09-10-2003, 04:23 AM
a_t_jackson a_t_jackson is online now
Registered User
 
Join Date: 03-11-2003
Location: Belfast, Northern Ireland
Posts: 23
Thanks for your help. I've finally got it to work by realising that the XML tags weren't requried and just including this section of your code in the STEP tab:

Function vbld_StepDone()
' look for the string ' failed' in the cabarc output and fail the build if found
If InStr(Application.Macros(vbldMacroSystem)("LASTSTE P_OUTPUT"), " failed") <> 0 Then _
Err.Raise 1, Step.Name, "cabarc utility failed"
End Function

One more problem...calling Err.Raise just seems to stop the Build without triggering my Failiure steps. Any ideas?
Reply With Quote
  #4  
Old 09-11-2003, 11:21 AM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
You can copy and paste XML step text into the step grid (not the step properties dialog) and it will create a new step with all the properties initialized.

There is currently a bug in that failure steps are not built when a failure occurs within a step's script event. As a workaround, you could instead place the script code a Run Script step following the cabarc step:

<step action='Run Script' type='0'>
<Language>VBScript</Language>
<Script><![CDATA[' look for the string ' failed' in the cabarc output and fail the build if found
If InStr(Application.Macros(vbldMacroSystem)("LASTSTE P_OUTPUT"), " failed") <> 0 Then _
Err.Raise 1, Step.Name, "cabarc utility failed"
]]></Script>
<indent type='3'>1</indent>
<name>test failure</name>
</step>
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 05:41 PM.


Copyright © 1999-2023 Kinook Software, Inc.