Dave Bowden
Posts: 4
Joined: Fri Apr 21, 2006 4:24 pm
Location: UK

Can I pass session properties to a BAT in a custom action?

I'm evaluating the product at the moment - it looks good!

The question I have concerns passing session properties to a .BAT script in a custom action as command line parameters. I am OK for running the batch job (using Viewer.exe) but cannot sort out the syntax for passing the session properties into the .BAT.

Can anyone help ? I guess its just a simple piece of syntax.
I've tried things like this without success so far:

[#LocalSecurity.bat] [APPDIR]
[#LocalSecurity.bat [APPDIR] ]

Thanks!
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

If the BAT file is an external file then define the "Property Name" that contains the path for the BAT file on "Install Parameters" page.

If the BAT file is contained in the package then you must create a "Property set with Formatted" that sets the property (path for the BAT file) from a formatted text string. The "Formated Text" contains the path for the BAT file like this:

Code: Select all

Formatted Text: [#test.bat]
In order to pass a Session Property as a command line parameter for a BAT file use "Property Source" as a custom action. The "Property Name" is the property that contains the path for the BAT file. The name of the property is not placed between brackets ( [] ). In the "Command Line" field type the Property (Formatted Type) that you want to pass as a parameter for the BAT file.

Regards,
Gigi
_________________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
Dave Bowden
Posts: 4
Joined: Fri Apr 21, 2006 4:24 pm
Location: UK

Think I understood yr suggestion but not quite there yet!

Hi Gigi,

Thanks for the reply. Here's what I've done, but without success as yet. Have I followed your suggestion OK? Any ideas? I wondered about the "Source Type: Executable (*.exe)" since this is a batch job?

I have a "Property set with formatted" action hanging off of the "CostInitialize" event (I read in help somewhere that the property needed setting before the "CostFinalize" event and guessed it didnt really matter where it sat other than that). it looks like this:
Property Name: BatchPath
Formatted text: [#LocalSecurity.bat]
Execution Properties, Execution Options, Scheduling Options all on top radio button choice

Then I added a Property Source action on the "WriteIniValues" event (far enough down the line for the files to have been installed) which looks like this:
Property Name: BatchPath
Source Type: Executable (*.exe)
Command line: [APPDIR] [New_Folder_2_DIR]

Execution Properties: Asynchronous execution, do not wait for return
(If I have a wait for return the install fails)
Execution Options: Immediate execution
Scheduling Options: Always Execute

Many thanks!!
Dave
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

The problem resides from the fact that you chose an "Immediate Execution" for the custom action and this means that the BAT file is executed before it gets copied. To solve this problem choose the "Deferred" execution option for the custom action.

All standard actions before "InstallInitialize" and after "InstallFinalize" are immediate.

An "Immediate execution" custom action will be executed immediately when it is found in the action sequence.

A "Deferred" custom action will be executed in order as part of the script built out of all the non-immediate actions.

If you place an "Immediate execution" custom action after "InstallInitialize" and before "InstallFinalize" it will be executed before all standard actions that belong in this interval.

Regards,
Gigi
_______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
Dave Bowden
Posts: 4
Joined: Fri Apr 21, 2006 4:24 pm
Location: UK

Immediate execution does not resolve

Hi Gigi,

Thanks for the tip, I've set it for deferred execution. However, no matter how I play with the entries I continue to get an error.
I am finding my way around the product more though :-) ! So here's an extract from the verbose log where the batch job fails to run. It looks to me like the "BatchPath" property is either empty or not coming through properly since all that is reported in these errors are the two paths I am passing as parameters to the batch job.
MSI (s) (C0:9C) [13:19:15:745]: Executing op: ActionStart(Name=PropertySource,,)
Action 13:19:15: PropertySource.
MSI (s) (C0:9C) [13:19:15:945]: Executing op: CustomActionSchedule(Action=PropertySource,ActionType=1074,,Target=D:\Program Files\Transition Associates\Transition Notes R7 Tutorial\ D:\WINNT\System32\Macromed\Flash\FlashPlayerTrust\,)
MSI (s) (C0:9C) [13:19:15:986]: Note: 1: 1721 2: PropertySource 3: 4: D:\Program Files\Transition Associates\Transition Notes R7 Tutorial\ D:\WINNT\System32\Macromed\Flash\FlashPlayerTrust\
Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: PropertySource, location: , command: D:\Program Files\Transition Associates\Transition Notes R7 Tutorial\ D:\WINNT\System32\Macromed\Flash\FlashPlayerTrust\
MSI (s) (C0:9C) [13:19:20:292]: Product: Transition Notes R7 Tutorial -- Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor. Action: PropertySource, location: , command: D:\Program Files\Transition Associates\Transition Notes R7 Tutorial\ D:\WINNT\System32\Macromed\Flash\FlashPlayerTrust\
This next extract is (I think) where the BatchPath property is being set in the "Property set with formatted" action.
MSI (c) (DC:30) [13:17:11:647]: Doing action: PropertySource_1
Action 13:17:11: PropertySource_1.
Action start 13:17:11: PropertySource_1.
MSI (c) (DC:30) [13:17:11:917]: Note: 1: 2753 2: LocalSecurity.bat
Action ended 13:17:11: PropertySource_1. Return value 1.


Hoping you can help me still ...

Regards
David
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

The problem resides from the fact that you put the "Property set with formatted" CA to be executed on "CostInitialize" event and at this time the BAT file is not marked for installation.

To avoid this problem put both CAs on "InstallFinalize" event to be executed as immediate and as an "Execution Condition" choose "(Not Installed)".

The "Property set with formatted" CA must be scheduled before the "Property Source" CA.

Regards,
Gigi
__________________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
Dave Bowden
Posts: 4
Joined: Fri Apr 21, 2006 4:24 pm
Location: UK

Hi Gigi

That did it, thanks.

I had some more fiddling around to do to pass the path parameters to the batch job within quotes and then strip out the quotes inside the batch job to cater for spaces in directory and file names but now it's working fine.

Thanks again.
Just deciding which edition of the product to buy now.

Regards
David
AnneTheAgile
Posts: 61
Joined: Wed Jun 08, 2011 9:53 pm

Re: Can I pass session properties to a BAT in a custom actio

For (me?) in the future, stripping quotes in a bat file can be done via the tilde search/replace function in BAT language.
http://stackoverflow.com/questions/1964 ... ith-cmd-en

I wish I could Modify a session property.

Return to “Common Problems”