ToddCostella
Posts: 5
Joined: Tue Mar 21, 2006 10:55 pm

Dialog(ue)s that write values to an ini file?

Greetings all, I was very excited to see the addition of the dialog editor in the latest release. We have a need for capturing a few environment type settings at installation time that will be picked up by our Java Swing app.

In reviewing the online help, it states that
Adding registry entries
As said before the gathered information will be stored in the Registry. Create the necessary registry entries to store the value of the SERVER_ADRESS, PORT_NUMBER and FIREWALL_SETTINGS properties as described in the Professional Installation tutorial.
My question is, do I have any other options for storing these values captured at installation time to another source other than the registry? We install into some (customer) environments that locked down to the point where the client workstations cannot write to the registry at all. It would be great if the dialog could write name value pairs into an ini file or some other simlar structure.

Stellar product by the way, we're really happy with it!

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

Hi,

Here is some vbs code that can help you to write data into an ini file:
http://www.motobit.com/tips/detpg_asp-v ... ini-files/

You can create a custom action that write the property value of a edit control to a ini file. Note that in vbs code you can access a windows installer property like this: Session.Property("PROPERTY_NAME").

Regards,
Gigi
_________________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
ToddCostella
Posts: 5
Joined: Tue Mar 21, 2006 10:55 pm

Thanks for the approach.

I'm not sure I understand how the Session.Property("PROPERTY_NAME") works though.

This is a little test I tried.

I created a new professional project
I added one file in the Files and Folders section
I added a edittbox called MY_EDIT_BOX with a property name of MY_EDIT_BOX_PROPERTY to the existing FolderDlg Dialog
I added a vbs script as an attached custom action to the Install node in the InstallExecuteSequence

I build and run my project
My editbox shows up on the installation dialog
When I complete the installation, the contents of my editbox do not get written to the file.

The source of my script is below:

Code: Select all

Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("c:\tmp\todd.ini", ForAppending, True)
    objTextFile.WriteLine(Session.Property("MY_EDIT_BOX_PROPERTY"))
objTextFile.Close
I know the script gets executed because there is a todd.ini file written to my tmp dir but it contains one empty line.

I've tried a few things including:

objTextFile.WriteLine(Session.Property("MY_EDIT_BOX"))
objTextFile.WriteLine(Session.Property("[MY_EDIT_BOX_PROPERTY]"))

If I hardcode some string into the WriteLine like
objTextFile.WriteLine(Session.Property("THIS IS A TEST")
this text does get written to the file.

So, there is something missing with the call to Session.Property()

Is there something I'm missing here?

Thanks for the help....


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

Hi,

With Session.Property("PROPERTY_NAME") you can access the value of the property named "PROPERTY_NAME" inside your VBS custom action.
When I complete the installation, the contents of my editbox do not get written to the file.
The property value is not written to the file because you schedule the custom action under "Install" section. Under this section by default all custom actions are added with "Deferred" execution option. Properties set during the install sequence are not available to a deferred custom action.

Change the "Execution Option" to "Immediate execution" for your custom action. Build and run your package.

If you have any other problem please let me know.

Regards,
Gigi
_________________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
ToddCostella
Posts: 5
Joined: Tue Mar 21, 2006 10:55 pm

Yes, that was it.

Thanks again for the help, muchly appreciated!

Todd
cpinstall
Posts: 19
Joined: Thu Jun 08, 2006 4:00 pm

EDIT: Nevermind. I put it the custom action in the "InstallFinalize" section and that did it.
gigi wrote: Change the "Execution Option" to "Immediate execution" for your custom action. Build and run your package.
Gigi,

I have a vbs script as a custom action that writes a file to [APPDIR]\filename.txt

This script is failing because APPDIR does not exist yet when the vbs script is executed. This happens when I change the "Execution Option" to "Immediate Execution" as you've specified above. Is there a way for me to execute the script AFTER the install, so that APPDIR exists?

I've tried moving the custom action to the "Commit" section but that still does not work.

Also, I've tried changing the "Execution Option" to "Deferred", but then I have the same problem as ToddCostella where the properies being written to the file are empty lines.

Any ideas on how to accomplish this?

Thanks.
Ionut
Posts: 605
Joined: Tue Nov 22, 2005 11:29 am
Contact: Website

Hi,

The APPDIR Property is set using a Custom Action before the "CostInitialize" stage in both sequences (InstallUISequence and InstallExecuteSequence), if it is not empty.

Hence, I do not believe that the Custom Action is failing because APPDIR is not set. Scheduling the CA on InstallFinalize should work correctly.

In order to determine why this happens please post the script (or the relevant lines) and specify where the CA is sequenced and what are its properties.

Regards,
Ionut
Denis Toma
Advanced Installer Team
http://www.advancedinstaller.com/
cpinstall
Posts: 19
Joined: Thu Jun 08, 2006 4:00 pm

The CA was sequenced on the "Commit" stage of "InstallExecuteSequence".

The Properties are:
Action Data: [APPDIR]
Execution Properties: Synchronous execution, check return code.
Execution Options: Immediate execution.

Code: Select all

Const ForAppending = 8
Dim appdir

appdir = Session.Property("CustomActionData")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile( appdir & "proxy.config", ForAppending, True)

objTextFile.WriteLine(Session.Property("AUTH_USER_PROP"))
objTextFile.WriteLine(Session.Property("AUTH_PASS_PROP"))

objTextFile.Close 
Ionut
Posts: 605
Joined: Tue Nov 22, 2005 11:29 am
Contact: Website

Hi,

The problem is that when the script is run, the directory structure does not yet exist and the call to the "OpenTextFile" method fails.

You need to move the Custom Action on the "InstallFinalize" stage. Also, change the following line:

Code: Select all

appdir = Session.Property("CustomActionData")
to this:

Code: Select all

appdir = Session.Property("APPDIR")
Leave the "Action Data" field blank, because an "Immediate" Custom Action does not have access to the "CustomActionData" Property (AI allows this artificially for this type of CA).

You would probably want to set the Execution Condition to: (Not Installed)

Regards,
Ionut
Denis Toma
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”