[izpack-user] Update the PATH and set an env var

586 views
Skip to first unread message

Florent Georges

unread,
Apr 22, 2012, 12:03:58 PM4/22/12
to us...@izpack.codehaus.org
  Hi,

  I am very new to IzPack, sorry if my question is a simple one, but I
couldn't find the answer in the doc.

  During the install of my soft (a Java-based application, with some
shell and batch scripts to help launching it), I'd like to add the
subdir bin/ to the system and/or user PATH, as well as setting an
environment variable (that my app uses to locate a specific dir; it
would be especially nice if the user could select this dir during the
install).

  Any idea? (how to update the PATH and set an env var)

  Regards,
 
--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Earl Hood

unread,
Apr 23, 2012, 12:11:56 PM4/23/12
to us...@izpack.codehaus.org
On Sun, Apr 22, 2012 at 11:03 AM, Florent Georges wrote:

>   During the install of my soft (a Java-based application, with some
> shell and batch scripts to help launching it), I'd like to add the
> subdir bin/ to the system and/or user PATH, as well as setting an
> environment variable (that my app uses to locate a specific dir; it
> would be especially nice if the user could select this dir during the
> install).

For modifing the search path (assuming you are talking about Windows), in
the project I'm involved with, we have a vbscript that gets invoked by
the installer to auto-update the search path to include the applications
bin directory. Unfortunately, one has to use something that is Windows
specific to access the system components for modifying the set of
environment variables (for Linux, one can usually just drop something in
/etc/profile.d).

IzPack provides the capability to invoke external programs during the
install process, so we just have it call the script at the end.

Here is an example XML fragment in a <pack> that tells IzPack to invoke
the script:

<executable targetfile="$INSTALL_PATH/bin/update-search-path.bat"
stage="postinstall"
failure="warn"
os="windows"
keep="true">
<args>
<arg value="-a"/>
<arg value='"$INSTALL_PATH"'/>
</args>
</executable>

The batch file listed just calls the vbs file that does the real work.

The $INSTALL_PATH variable is set by the standard TargetPanel.

--ewh

Dirk Räder

unread,
Apr 25, 2012, 2:41:46 AM4/25/12
to us...@izpack.codehaus.org
2012/4/23 Earl Hood <ea...@earlhood.com>:

Hi,

there was a question regarding reading from and writing to the Windows
registry. I've developed some actions to do exactly that - you can
download them from https://gist.github.com/1789030

For setting an global environment variable, use this configuration:
<Action>
<Root value="HKLM" />
<Key value="SYSTEM\CurrentControlSet\Control\Session Manager\Environment" />
<Name value="$VariableName" />
<Value value="$DesiredValue" />
<Mode value="prepend|append|overwrite" />
<CreateIfNew value="true|false" />
</Action>

For setting the current user's environment variable, use this configuration:
<Action>
<Root value="HKCU" />
<Key value="Environment" />
<Name value="$VariableName" />
<Value value="$DesiredValue" />
<Mode value="prepend|append|overwrite" />
<CreateIfNew value="true|false" />
</Action>

To edit the system search path, you should use either append or
prepend as value for Mode.

Prepend makes sure the executables installed by your installer are
found first. This may change the system's behavior: other executables
that were found with the old path will no longer be found.

Append makes sure only those of your executables that were not found
using the old path will now be found.

Kind regards,

Dirk

Reply all
Reply to author
Forward
0 new messages