[izpack-user] Problem with RegistryUnistallListener

170 views
Skip to first unread message

Mario Burdman

unread,
Feb 17, 2015, 10:18:49 AM2/17/15
to us...@izpack.codehaus.org
Hi guys!

I'm having a problem with RegistryUninstallListener. For some requirements I had to wrap izpack installer using launch4j and I had to embed a jre that is used to run installer and copy over to program installation directory and then used it on my nb platform app.

I added the following to my script to be able to uninstall from control panel:

    <listeners>
        <listener installer="RegistryInstallerListener" uninstaller="RegistryUninstallerListener" >
            <os family="windows"/>
        </listener>
    </listeners>

    <native type="3rdparty" name="COIOSHelper.dll" stage="both">
        <os family="windows"/>
    </native>
    
    <native type="3rdparty" name="COIOSHelper_x64.dll" stage="both">
        <os family="windows"/>
    </native>

Everything is working great, I certainly know the jre that is being used to install and using same jre to run my program.

The problem I have is that my app is installed from a DVD and when I try to uninstall, if I don't have the DVD on the drive it fails because is trying to use the jre from the DVD to run uninstaller, on the registry I see (E: is my DVD drive):

UnisntallString = "E:\jre\bin\javaw.exe" -jar "C:\Program Files (x86)\<Company>\<Product>\uninstaller\uninstaller.jar"

I wonder if there is a way to overwrite this value to use the path to jre that I copied to the installation directory instead of using the one on the DVD.

I found some documentation and questions that uses:
keypath="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$APP_NAME $APP_VER"

But I have to handle 32 and 64 bits platforms, so, sometimes the entry will be on "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node".

I'd appreciate any hint on this.

Using izPack 4.3.5, I need to target Windows XP to Windows 8.

Thanks in advance!

--
Mario

Yaffe, Lior

unread,
Feb 17, 2015, 11:11:12 AM2/17/15
to us...@izpack.codehaus.org

I'm actually having the same issue, but pointing the uninstall key to the JRE in the installation directory won't help since the JRE will try to uninstall itself and fail so you'll get the uninstall error dialog (at least in 5.0)

I did not found a complete solution to this problem yet.

Mario Burdman

unread,
Feb 18, 2015, 10:28:50 AM2/18/15
to us...@izpack.codehaus.org
Hi Yaffe,

thanks, and good point!

I'm thinking on creating a native uninstaller, but it's a problem, because I have many similar products and will need one uninstaller for each... but thats another story...

If you don't mind, how did you customized the UninstallString to use the copied jre?

Thanks

--
Mario


Paul Bors

unread,
Feb 18, 2015, 1:00:41 PM2/18/15
to us...@izpack.codehaus.org
You have full control of how those registry keys are created.

I'm not sure why your uninstall string starts with "E:\jre\bin\javaw.exe"  morre so, that seems like a bug to be. Looks at what the command is trying to do, is trying to start Java off your CD. It should use the registered system path.

Let me ask you this, when you installed the app, did you have Java installed on the E: drive?

I would open a bug for this.
--
~ Thank you,
   Paul Bors

Yaffe, Lior

unread,
Feb 18, 2015, 3:23:19 PM2/18/15
to us...@izpack.codehaus.org

See "Registry access (InstallerListener and UninstallerListener)" in http://izpack.org/documentation/custom-actions.html

 

In install.xml <resources> I added:

        <res id="RegistrySpec.xml" src="RegistrySpec.xml"/>                           

 

Then implemented the following RegistrySpec.xml:

 

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<registry version="5.0">

 

    <pack name="UninstallStuff">

        <!-- Special "pack", if not defined an uninstall key will be generated automatically -->

        <!-- The variable $UNINSTALL_NAME can be only used if CheckedHelloPanel will be used

               because there the variable will be declared. With that variabel it is possible

               to install more as one instances of the product on one machine each with an

               unique uninstall key. -->

        <value name="DisplayName"

               keypath="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$UNINSTALL_NAME"

               root="HKLM"

               string="$UNINSTALL_NAME"/>

        <value name="UninstallString"

               keypath="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$UNINSTALL_NAME"

               root="HKLM"

               string="&quot;$INSTALL_PATH\jre\bin\javaw.exe&quot; -jar &quot;$INSTALL_PATH\uninstaller\uninstaller.jar&quot;"/>

        <value name="UninstallString"

               keypath="SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$UNINSTALL_NAME"

               root="HKLM"

               string="&quot;$INSTALL_PATH\jre\bin\javaw.exe&quot; -jar &quot;$INSTALL_PATH\uninstaller\uninstaller.jar&quot;"/>

    </pack>

</registry>

Paul Bors

unread,
Feb 18, 2015, 3:29:54 PM2/18/15
to us...@izpack.codehaus.org
Right, but one should not have to do so.

The default value the installer inserts in the registry is wrong.
This is a bug.

Yaffe, Lior

unread,
Feb 18, 2015, 3:35:10 PM2/18/15
to us...@izpack.codehaus.org

But if there is no Java version installed on the client workstation ?

 

IzPack uninstall procedure needs Java to invoke uninstaller.jar and in some cases the only Java available is one used to start the installer,  

in many cases it is on a removal media or in %TEMP% folder, what can you do in case it is no longer available ?

 

Mario suggested to install Java as part of the installation and point the uninstaller to use this version, but this won't help since the uninstaller would try to uninstall the Java version running the uninstaller and fail.

Paul Bors

unread,
Feb 18, 2015, 3:59:19 PM2/18/15
to us...@izpack.codehaus.org
Right, and why is izPack using the location of where the installer run from to write to the windows registry where the uninstaller starts from?

That's the bug. The value written there should be where the application was installed to.

You manually fixed the bug by working around it when you had to adjust the windows registry keys yourself. Are we expecting every developer out there that's using izPack to override the windows registry keys? Are should we fix the default values that izPack uses to where the installer wrote its files?

Mario Burdman

unread,
Feb 18, 2015, 4:07:54 PM2/18/15
to us...@izpack.codehaus.org
Hey Paul,

E is a DVD, and I used a jre I bundle with the dvd. 

I need to be sure the app is installed using Java 1.7 32 bits and I need to be sure the program runs with that version too. I also need to have the izpack installer wrapped on a exe to be able to "Run as Admin" with right click.

So, I bundle the jre on my dvd and the installer is using it, and thats why the uninstaller is trying to also use it.

I copy the jre as part of the instalation to a certain place and indicate my netbenas platform app to use it.

Ok, now the problem Yaffe is pointing is that I will not be able to use the jre that I want to remove as part of the uninstalation.

My options are: 
- create another way to uninstall the app
- assume there is a java version installer on the computer and in the path.

I both options I need to customize UninstallString. I looked at documentation, I assume I can overwrite tha value written by "RegistryInstallerListener" using keypath="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$APP_NAME $APP_VER". BUT, I have to support 64 and 32 bits platforms and the registry path is different!

Hope I'm being clear with the explanation... :)

--
Mario



Mario Burdman

unread,
Feb 18, 2015, 4:09:23 PM2/18/15
to us...@izpack.codehaus.org
Sorry guys, I didn't see your replyes while writing my last email, just Paul's.

Mario Burdman

unread,
Feb 18, 2015, 4:24:40 PM2/18/15
to us...@izpack.codehaus.org
Ok, now I read your email :)

Paul, I don't see a way that izPack could know where and IF there is a java more that the used to install. I could not even copy the jre to the hard drive.



Yaffe, for multiplatform issue, maybe I should switch using:

<listeners>
        <listener installer="RegistryInstallerListener" uninstaller="RegistryUninstallerListener" >
            <os family="windows"/>
        </listener>
    </listeners>

    <native type="3rdparty" name="COIOSHelper.dll" stage="both">
        <os family="windows"/>
    </native>
    
    <native type="3rdparty" name="COIOSHelper_x64.dll" stage="both">
        <os family="windows"/>
    </native>

to a 100% customized approach like you, where I certainly know where the keys are.


btw, many thanks guys!


--
Mario

Paul Bors

unread,
Feb 18, 2015, 6:15:19 PM2/18/15
to us...@izpack.codehaus.org
Mario, you miss understood the bug here.

The installer copies Java itself to "<installation path>\jre\bin\javaw.exe" but when it write to the registry it does not use the <installation path> but rather it uses <path where the installer runs from> or at the very least the letter drive where the installer is running from.

That's the bug.

Paul Bors

unread,
Feb 18, 2015, 6:20:05 PM2/18/15
to us...@izpack.codehaus.org
Hey Mario, yes this is a classical windows problem.

And this is why I would take this bug one step further and attempt to use a different instance of Java installed on the host PC and if one can not be found, then use the one shipped with the installer.

Now you run into another bug, where you start the uninstaller from "<installation path>\jre\bin\javaw.exe" which windows will have file pointers opened to. You will run the uninstaller which will keep a second file pointer open to.

So how do you get rid of all those files now?

Well the uninstaller must be changed to work in 2 steps:
1) Copy itself to a different temp folder
2) Start from the temp folder and uninstall the actual stuff from <installation path>

This 2 step will free up the file pointer to the uninstaller itself in the <installation path> and since it runs from a temp folder Windows will later clean up its own copy.

Now, if you're going to use the JVM from "<installation path>
\jre\bin\javaw.exe" then don't expect to delete that file LOL

Mario Burdman

unread,
Feb 20, 2015, 11:01:25 AM2/20/15
to us...@izpack.codehaus.org
Hey Paul, 

I think you are missing a part, I don't think it's an izPack related problem.

I'm wrapping the installer with launch4j and saying launch4j to use a bundeled jre to run the installer.
IzPack is not aware of anything else, the one and only jre that is aware is the one I indicated to use from launch4j.
In one step I copy a folder to the hard drive, it's a jre, but izPack is not aware of that.

Do you still see a bug? I might be missing something, like I did when tried to remove jre using that jre LOL :)

--
Mario







Paul Bors

unread,
Feb 20, 2015, 3:45:03 PM2/20/15
to us...@izpack.codehaus.org
LOL I never mentioned a JRE outside of the scope of having one on the PC so you can run Java.


The bug is clear, izPack is writing the wrong value to the windows registry and you have to fix it by hand. Instead of using the path where the app installed its own java, is using the installation media driver letter.

Mario Burdman

unread,
Feb 20, 2015, 4:01:04 PM2/20/15
to us...@izpack.codehaus.org
But this way, I should ask java installed as prerequisite (and IMO is a good idea, lets see what's my customer opinion :))

Supose I don't need even need java to run my program, and I never copy the jre to the hard drive, there is no more java than the one on the DVD.
Not saying that this makes sense, since I need java to run unisntaller.jar, but my point is: there is no way for izPack to know if and where is java.

If I don't tell Launch4j to use my bundeled jre, everything works ok, in fact it has been working OK since years of the product on the market :(.


Cheers!

--
Mario

Paul Bors

unread,
Feb 20, 2015, 4:37:58 PM2/20/15
to us...@izpack.codehaus.org
Dude, the installer copies the java exe there but then writes to the windows registry the wrong driver letter.

Are we still on this?

Mario Burdman

unread,
Feb 20, 2015, 5:10:09 PM2/20/15
to us...@izpack.codehaus.org
On Fri, Feb 20, 2015 at 6:37 PM, Paul Bors <pa...@bors.ws> wrote:
Dude, the installer copies the java exe there but then writes to the windows registry the wrong driver letter.

The installer *needs* java to run, and suppose there is no java on the computer, the only java is the one on the DVD, izP is just using the only known java.
I am copying it as part of the instalation, I could not do that, just doing because its my need. 

How could the installer copy the jre to use if itself needs jre to run?

See my point? I still don't see how izPack could use other java for uninstaller than the one used to run the installer, in this case, the one on the DVD.

--
Mario

Paul Bors

unread,
Feb 23, 2015, 11:08:38 AM2/23/15
to us...@izpack.codehaus.org
The installer *needs* java to run, and suppose there is no java on the computer, the only java is the one on the DVD, izP is just using the only known java.
I am copying it as part of the instalation, I could not do that, just doing because its my need.
Yes, that's good, now you ensure there is a JRE installed (although you could check the windows registry and see if one's already installed, but that's another story).

How could the installer copy the jre to use if itself needs jre to run?
When you create the uninstaller windows registry entry to start the uninstaller, why are you using the drive letter from the installation media? I certanly did not installed from CD to CD to uninstall from CD.... Do you understand the bug is in the driver letter written to the windows key for the uninstaller to start up? You're using the installation media not the drive letter of where the uninstaller was written to.

Paul Bors

unread,
Feb 23, 2015, 11:11:36 AM2/23/15
to us...@izpack.codehaus.org
Ie: During installation copy the JRE to the installation folder then for the uninstaller use the new JRE you just copied.

It will leave the folder behind because during uninstallation you'll have file pointers opens to the JRE in use by the uninstaller. To circumvent that, you have to make the uninstaller work in 2 steps:
1) Copy the JRE to a tmp folder
2) Start the uninstaller again with the JRE from the tmp folder

That's option for now... let's get straight how the uninstaller starts without the installation media in the CD drive.

Yaffe, Lior

unread,
Feb 24, 2015, 1:26:01 AM2/24/15
to us...@izpack.codehaus.org

Hi Paul,

 

I'll try to clarify the remaining uninstall problem we have when installing on a machine which has no JRE:

1.       The uninstaller needs JRE to run.

2.       If it relies on the JRE used for running the installer – this JRE may not be available when the user tries to uninstall since it is not "installed".

3.       If it relies on another JRE installed by installer – the uninstaller tries to uninstall this JRE since it was installed by the installer, and show error messages during uninstall.

 

In my view the solution should as follows:

1.       A property setting letting the developer to set the JRE path to invoke in the uninstall command in the Windows registry thus removing the need for implementing the registry spec xml.

2.       IzPack should know not to attempt to uninstall the JRE which invokes the uninstaller.jar and it should not write any warning messages.

3.       There should be additional procedure to remove this JRE later – I'm not sure how this can be done. We need to experiment with ways for a JRE to delete itself. For a start this should be documented as limitation.

 

Lior

 

From: Paul Bors [mailto:pa...@bors.ws]
Sent: Monday, February 23, 2015 6:11 PM
To: us...@izpack.codehaus.org
Subject: Re: [izpack-user] Problem with RegistryUnistallListener

 

Ie: During installation copy the JRE to the installation folder then for the uninstaller use the new JRE you just copied.

Lior Yaffe

unread,
Feb 24, 2015, 10:26:53 AM2/24/15
to us...@izpack.codehaus.org
Doesn't work since the uninstaller tries to uninstall this JRE but its locked since it is running the uninstaller.

Yaffe, Lior

unread,
Feb 24, 2015, 11:00:12 AM2/24/15
to us...@izpack.codehaus.org

Sorry, I misread your response.

 

How do I customize the uninstaller to copy the JRE to a temp folder ?

Should I create a batch file which copies the JRE to a temp folder and then invokes the uninstaller Jar ?

But then I need to implement registry spec xml to invoke the batch file …

 

Also I'm not sure if the uninstaller can uninstall a running batch file.

Paul Bors

unread,
Feb 24, 2015, 4:46:12 PM2/24/15
to us...@izpack.codehaus.org
The uninstaller itself should copy the JRE to a tmp folder and write a batch file that starts a new process from the tmp folder.

Upon exit it should start the other process and then call System.exit().

In the new process the normal uninstlalation starts.

That's the lame 2 step uninstallation I proposed.


Have we fixed the problem of writing the wrong driver letter to the windows registry key that starts the uninstaller off the CD (installation media)?

Paul Bors

unread,
Feb 24, 2015, 4:52:57 PM2/24/15
to us...@izpack.codehaus.org
For windows, the first step would look something like:
Process p = Runtime.getRuntime().exec("cmd /c cp <path to JRE> <TMP Folder>");
p.waitFor(); // or whatever the method was, I forgot it top of my head
p = Runtime.getRuntime().exec("cmd /c <TMP Folder>/java <path to uninstaller>");
System.exit();

Now you should prob. copy both the JRE and the Uninstaller to the TMP folder since both will keep file pointers open to the folders you want to delete.

Paul Bors

unread,
Feb 24, 2015, 4:54:17 PM2/24/15
to us...@izpack.codehaus.org
Make sure you increment a number in those file names since there might be multiple such files names in the TMP folder.
Reply all
Reply to author
Forward
0 new messages