Guest

Variables within a script

Is it possible to create a variable that can be substitued within .bat and configuration files during installation? For instance, I have a batch file that starts up the application, in it I need to set the JAVA_HOME variable that points to the distribution of JAVA that we ship with the product. I'd like to be able to do something like;

JAVA_HOME=[TARGETDIR]\jdk-1.5.0

and have it replace it with the full path.

In other places, I'd like to set the default working directory (defined as a variable in a configuration file) to point to the target directory of the installation followed by the path to the working directory.

Right now I'm just evaluating the product and have used environment variables to achieve this for the startup file but I'm unable to do this for the config file.

Nice product otherwise.

Thanks!
UdreaMihai
Posts: 90
Joined: Wed Mar 23, 2005 8:13 am

Hello,

You don't have to use such a .bat file.
Advanced Installer has the ability to generate an installer package which bundles the Java Runtime Environment you specify. This JRE will be placed alongside with your application and it will be used when starting it.
Check the AI Help for more information:
http://www.advancedinstaller.com/featur ... aller.html
http://www.advancedinstaller.com/user-g ... -java.html
Hope that it helps.

Best,

Mihai
Udrea Mihai
Advanced Installer Team
http://www.advancedinstaller.com
Perry

Perhaps but...

Actually I need to install a compiler although that probably doesn't matter.

It still doesn't address the application configuration files that need to be updated with various paths that are relative to the installation directory.

One last thing. The application creates files in the users home directory. There is an option to put files into the My Documents folder but not the user's actual home directory. Is there a way to add this directory to the list of available locations for files?

Thanks again,

Perry.
Cata
Posts: 638
Joined: Thu Apr 10, 2003 7:37 am
Contact: Website

Hi Perry,

Windows Installer supports updating of configuration data on install in the following places:
- Registry (which in Java can be accessed from Preferrences)
- INI files
- Environment variables.

Updating of .BAT files is not supported.

Cata
Catalin Rotaru - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
UdreaMihai
Posts: 90
Joined: Wed Mar 23, 2005 8:13 am

Hello,

You can create files in the user's home directory using 2 custom actions, one of which is already in Advanced Installer.

In your custom action you have to set a property you have already created with the user home directory path. Then you can use the "Directory Set With Formatted" from "New Custom Action" to modify the folder that you want, let's say AppDataFolder. Schedule it after CostFinalize. In the "Formatted text" editbox you must enter the [windows volume] folder and your property name between square brackets: e.g. [WindowsVolume][myproperty]. If you use a VBScript custom action you can find the user's home directory by using the following command:

Set Shell = CreateObject("WScript.Shell")
home = Shell.ExpandEnvironmentStrings("%HOMEPATH%")

You must remove the first back-slash from the "%HOMEPATH%" variable. First, it will be something like: "\Docum...\User". Then you have to set your property with that value: e.g. "Docum...\User".

Let me now if it works.

Best,

Mihai
Udrea Mihai
Advanced Installer Team
http://www.advancedinstaller.com

Return to “Common Problems”