Archive: Uninstall deleted all files under Program Files


Uninstall deleted all files under Program Files
Have been using this installer for a few months now, it's fairly simple - just copies files to an installation directory.

Problem was that on one instance of the uninstall in addition to it's own installation directory it also wiped out the contents of Program Files.

Any ideas why this might have occurred and how I can be sure to prevent this?

The only thing I can think of is that the "${PRODUCT_DIR_REGKEY}" happened to be a duplicate of another product of ours that was also installed. I dont' actually know what this key is used for - it was inserted by the HM NIS wizard.

Here's my uninstall section, any help would be appreciated.

Section Uninstall
Call un.KillPro
Delete "$INSTDIR\${PRODUCT_NAME}.url"
Delete "$INSTDIR\uninst.exe"
RMDir /r "$INSTDIR\plugins"
RMDir /r "$INSTDIR\common"
Delete "$SMPROGRAMS\ClearCanvas Ris Client\Uninstall.lnk"
Delete "$SMPROGRAMS\ClearCanvas Ris Client\Website.lnk"
Delete "$DESKTOP\ClearCanvas Ris Client.lnk"
Delete "$SMPROGRAMS\ClearCanvas Ris Client\ClearCanvas Ris Client.lnk"
RMDir "$SMPROGRAMS\ClearCanvas Ris Client"

RMDir /r "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
SectionEnd


RMDir /r "$INSTDIR"

That call causes the installer to remove the whole $INSTDIR tree recursively, regardless of whether or not it is empty. If $INSTDIR happens to be Program Files, then it will delete everything in Program Files.

This is from the scripting reference: "Warning: using RMDir /r $INSTDIR in the uninstaller is not safe. Though it is unlikely, the user might select to install to the Program Files folder and so this command will wipe out the entire Program Files folder, including other programs that has nothing to do with the uninstaller. The user can also put other files but the program's files and would expect them to get deleted with the program. Solutions are available for easily uninstalling only files which were installed by the installer."