Another post on something that happened last week, this time it’s about a Java based Application again.

This particular application wanted to download three DLL’s from the Webserver to the Java bin directory.

This presents us with several issues on a multi user server such as a Citrix of Terminal Server:

  1. The user does not have write permissions in this directory
  2. If we we give the user write permissions here what happens when the DLL’s are in use by another user?

I assumed that if I preinstalled the DLL’s the application wouldn’t try to overwrite them but that didn’t work.

Then I monitored with Process Monitor if the Application wrote some kind of check file but at first I didn’t find anything.

So I decided to use the CorrectFilePaths shim to redirect the DLL’s to the user’s homedirectory (see Using the CorrectFilePaths shim to redirect an ini file to a writable location for an explanation).

This worked nicely, I started the Application and saw the files being downloaded to the user’s homedirectory.

Side note: this downloading took a much too long time because it downloads byte by byte, #crappy!

I tested a few things in the application according to the instructions and everything seemed to work fine. Then I closed the Application and finally the Browser.

And then an error message came, indicating that the Application couldn’t a write a file called into the Java Home directory.

I then redirected this file as well and checked the content and it’s an ini alike file:

I then removed the CorrectFilePaths shim and place the file in the Java Directory and the DLL’s in the bin directory.

Now everything worked well but of course the challenge is how to package this.

The easiest approach is to have the installer copy the files but what happens if a file is already present?

I think it’s risky to blindly write this file so I wanted to an installer that does the following:

  • Dynamically determine Java Folder
  • Create the file if it doesn’t exist
  • Add’s the DLL entries to the file
  • Does not overwrite existing entries
  • Does not write the lines if they already exist
  • On Uninstall remove the DLL files
  • On Uninstall remove the lines from the file

I used Innosetup for this Task because it has a very nice scripting engine that makes this task a breeze. And best of all: Innosetup is free.

Below my Setup.iss script, I think the script parts contains enough comments to explain the code. But if you have any questions please leave a comment.

If you want to use the script, combine the setup and code part to one .iss file and compile it.
The setup part:

And the script part: