Archive: InstallDirRegKey and Uninstaller


InstallDirRegKey and Uninstaller
hi,

I use both functions

InstallDir ${path}
InstallDirRegKey HKLM ${mainpath} "InstallLocation"

in directory page by running I change the path.

Uninstaller uses old path.
Schall Uninstaller read the registry for new path?

thanks


Taken from the Help File.. Should help..

$INSTDIR

The installation directory ($INSTDIR is modifiable using StrCpy, ReadRegStr, ReadINIStr, etc. - This could be used, for example, in the .onInit function to do a more advanced detection of install location).

Note that in uninstaller code, $INSTDIR contains the directory where the uninstaller lies. It does not necessarily contain the same value it contained in the installer. For example, if you write the uninstaller to $WINDIR and the user doesn't move it, $INSTDIR will be $WINDIR in the uninstaller. If you write the uninstaller to another location, you should keep the installer's $INSTDIR in the registry or an alternative storing facility and read it in the uninstaller.


oh-oh;
it would mean:
Section "Uninstall"
RMDir "$WINDIR"
SectionEnd

I will do a MessageBox that ask, delete or not,
if $INSTDIR not like default install location.

I expected, that InstallDirRegKey set $INSTDIR
by running of uninstaller.

thanks!


urrr.... no
I think you understand wrong about $WINDIR (The help file was just talking about $WINDIR as an example, for those BAD installers that place the Uninstaller program inside WINDOWS directory)

My recommendation would be to generate your Uninstaller in the $INSTDIR directory, rather than in $WINDIR


SetOutPath "$INSTDIR"
WriteUninstaller "Uninstall.exe"



So that when the Uninstaller is run (from inside the installation dir), the $INSTDIR is already correct, and match the directory choosen by the user in the installer

OK,
normally is it so,
but somebody can choose c:\windows or c\programm files as install directory.
or one can move unistaller into other directories without intent.

I use

Function .onVerifyInstDir

${If} "$INSTDIR" == "$WINDIR"
Abort
${EndIf}

FunctionEnd

but if deinstaller delete only files and dirs, that were installed, it's no problem.

I used RMDir /r $INSTDIR and it's wrong.
must be corrected.

thanks!


Right..
if you delete only the files you installed, then it should be ok
if you do a RMDir /r $INSTDIR, then you might have a problem


But if a user choose the "Program Files" or WINDOWS directory to install a program, he is going to be in trouble anyway
(for example, you might be replacing an existing -potentially system- file during installation)

I myself have used RMDir /r $INSTDIR in some of my installation scripts, so I'm starting to wonder if I shouldn't add a .onVerifyInstDir function like you suggest, just to prevent a dumb user from doing something bad


If you really want to handle the case where the user moved the uninstaller without intent, you might want to compare the $INSTDIR with the path taken for the registry (Add/Remove program) if you use it


ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\<your_app>" "InstallLocation"

and then prompt a dialog if the path are different

the good way.

my installer hadn't directory page,
InstDir was hardcoded.
I generated and put uninstaller on cd with installer.
But after adding directroy page, I become this questions with uninstaller pathes.
possible, it's not good idea, to put uninstaller on cd.
(for example if user delete uninstaller).

RMDir /r $INSTDIR is very dangerously.

Now, my uninstaller delete the directories, that were copied by installer.
I have a custom unpage with checkbox (Delete $INSTDIR?)
(would be good to implement this checkbox into directory page) and if $INSTDIR after deleting of directories and files is empty, I delete it too.

StrCpy $0 "$INSTDIR"
Call un.DeleteDirIfEmpty


$INSTDIR can be $WINDIR,
if user set in directory page c:\windows\assembly\.. for example.
also it's not really protected with this version of .onVerifyInstDir