Restoring original files at component uninstall - Advanced Installer Community
NeverUseQ
Posts: 7
Joined: Fri Jan 23, 2015 2:33 pm

Restoring original files at component uninstall

I'm using file operations at the the time of component install to create a backup instance of a file. This succeeds...
I'm using a similar file operation at the time of component uninstall to copy OR move the original file back to it's original name and location.... and this part doesn't work. I'm not sure why.

Can anybody shed light on how to back up unaltered files prior to an install and how they're putting them back should the package be uninstalled?

Thanks in advance!
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Restoring original files at component uninstall

Hello,

This may happen if the following conditions are met:
1. during installation the product is installed to a different location that the default path (e.g. "[ProgramFilesFolder][Manufacturer]\[ProductName]") set in "Install Parameters" page for "Application Folder" directory
2. you are using the "Application Folder" directory (APPDIR property) or one of its sub-folders in the source/destination paths of your file move operation scheduled on uninstall

In this case, on uninstall, the file move operation will fail to correctly resolve the source file path, and therefore won't find the source file. This is because the "APPDIR" property is always set to its default path (from "Install Parameters") at each setup run (install, maintenance or uninstall).

In order to avoid this behavior, as a workaround, you can create at install time a registry value (i.e. "Path") which will store the installation path (APPDIR property) and, then on uninstall add a search which will get the installation path from registry and set it in the "APPDIR" property. Here are a step by step procedure:
1. go to "Registry" page and create under "Software\[Manufacturer]\[ProductName]" a registry value like this
  • Name: Path
    Data: [APPDIR]
2. go to "Search" page and add a new search (MY_SEARCH)
3. select the above search, from its context menu choose "Add Location -> Registry" and configure the registry search like this:
  • Key: Software\[Manufacturer]\[ProductName]
    Name: Path
    Type: Retrieve the raw value
4. go to "Custom Actions" page and add a "Set installer property" custom action with sequence (scheduled only on uninstall), after "Install Execution Stage -> Searches" action group, like this:
  • Property: APPDIR
    Value: [MY_SEARCH]
5. rebuild and test again the scenario

Let us know if this helped, otherwise please send us the .aip (project file) to support at advancedinstaller dot com so we can investigate its settings.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
NeverUseQ
Posts: 7
Joined: Fri Jan 23, 2015 2:33 pm

Re: Restoring original files at component uninstall

Daniel I guess I don't fully understand what your program does. Seems like it's missing a piece...

Installation
1. In the first part, I define a registry entry that will detail where I'm keeping my NTUSER.ORG file.

Uninstallation
2. In the second part, I use a search command to locate and read the entry into a variable {NTUSERORG]

3. In the final part, I set a property during uninstall saying "here's my path"...



But nothing here says this is what you do with it once you find it... What am I missing?
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Restoring original files at component uninstall

Hi,

What my colleague Daniel meant, is to keep your "File Copy/Move" operations as you configured them before and also implement into your project the steps that he detailed. These steps are required for the package to know its installation path during the uninstallation and to copy the file to that location.

If you cannot get this to work, can you please send us the .AIP (project file) and two verbose logs (of the installation and uninstallation of your package), to support at advancedinstaller dot com, so we can investigate them?

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
NeverUseQ
Posts: 7
Joined: Fri Jan 23, 2015 2:33 pm

Re: Restoring original files at component uninstall

Here are the install, uninstall, and AIP files you've asked for.
Attachments
NeverUseQ-Bundle.zip
(27.99 KiB) Downloaded 283 times
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Restoring original files at component uninstall

Hi,

I looked over the files that you sent and also tested your scenario and indeed, the file is not copied during the uninstall of the application.This happens because the installer keeps in use the DAT file that should be replaced and it cannot be overwritten.

In order to achieve what you want, you can try to create a custom action that moves the ORG file to the desired location, then place that custom action after the "Add Resources" action group with the "deferred" and "no impersonation" options checked.

You can take a look on the How to uninstall an existing application thread which debates a similar problem.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”