kiage
27th November 2007 15:20 UTC
get INSTDIR in uninstaller.exe
My application can be installed more than once on the same system with different installation dirs, registry keys, ports, etc. for example
c:\Program Files\AAAA this is the default
c:\Program Files\XXXX
When I want to uninstall one of those I need to determine which instance should be removed.
I planned to do this by reading a file from $EXEDIR of the uninstaller. Unfortunately
c:\Program Files\XXXX\uninstall.exe
is first unpacked to a temp directory and then an executable Au_.exe is started. For this programm it is
$EXEDIR = c:\Temp\~nsu.tmp
$EXEPATH = c:\Temp\~nsu.tmp\Au_.exe
$INSTDIR = c:\Program Files\AAAA\uninstall.exe
the value of the default installation directory.
So how could I determine, which instance to remove?
Andy ideas?
Thanks, Andre
galevsky
27th November 2007 15:40 UTC
I am not sure to understand what you wanna do..... what the pb when reading from "$INSTDIR\foo.txt" ? ($INSTDIR contained in the uninstaller was set during the installation, so if it was installed in C:\Program Files\XXXX, it will read C:\Program Files\XXXX\foo.txt and not the C:\Program Files\AAAA\foo.txt one)
Gal'
kiage
27th November 2007 16:29 UTC
Thanks for pointing this out. I had seen this in the documentation, but it was not what my debugging code showed me.
Unfortunately I have overlooked something the previous programmer did:
ReadRegStr $INSTDIR HKLM "$REGKEY" Path
Removing this statement gave me what I need.
Thanks for the excellent answer,
Andre
galevsky
27th November 2007 16:46 UTC
was a pleasur'
staffan
5th March 2008 14:53 UTC
I have a simmilar problem. When I run the uninstall.exe $INSTDIR is correct, but it I run an installer and it says I already have the program installed and choose to uninstall the existing version $INSTDIR seems to be the default value rather then where I installed it.
galevsky
5th March 2008 15:15 UTC
Originally posted by staffan
I have a simmilar problem. When I run the uninstall.exe $INSTDIR is correct, but it I run an installer and it says I already have the program installed and choose to uninstall the existing version $INSTDIR seems to be the default value rather then where I installed it.
Of course. Your installer doesn't know if you have already installed your soft in c:\Program Files\Already\. But, during the installation, if the uninstaller is generated at the end, the uninstaller keep the information "installed under C:\Program Files\Already".
So, how can you do to know wether your soft is already installed or not ? Use Windows register keys to do that...
During the install process, check for the key existance (you can define some variables like version, company, install_path and so on...) then warn the user if already installed. In the end of the process, don't forget to write the key into the register with the good values....
That's all.
Gal'
staffan
5th March 2008 15:20 UTC
Originally posted by galevsky
So, how can you do to know wether your soft is already installed or not ? Use Windows register keys to do that...
Yes, that's what I do. It's when the old version is to be uninstalled the problem occurs.
I think I've managed to find the problem. In
PageLeaveReinstall it calls
ExecWait '$R1 _?=$INSTDIR' and that means it calls
C:\Dir\ActuallyInstalled\Uninstall.exe _?= C:\Dir\ThinkItsInstalled and that ofcourse gets all wrong.
galevsky
5th March 2008 15:44 UTC
Good.
I used to store tmp var in a tmp.ini file (deleted in the end) where I read/write all my persistent var.... so I am sure not to mix up.
Gal'
staffan
5th March 2008 16:23 UTC
I solved it by using the path from the old installation as
ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString"
and then trimming it
${GetParent} "$R1" $R4
ExecWait '$R1 _?=$R4'
galevsky
5th March 2008 16:38 UTC
well-done.