Background: Customer has changed the name of the application. The application has stored files under AppData folder and now that folder needs to be copied to new name (and d
Application Launch Sequence: If these are userprofile files
- in other words writable by the launching user of the application - then it is much better to do this cleanup in the application launch sequence. Crucially this will make the operation run for every users, and not just the user installing the setup
. It is a common mistake to forget to do the rename for all users on the box. This is assuming that these are per-user files (copies for each user), and not shared files for all users in %ALLUSERSPROFILE%
(only writable for admin users).
MSI Complexity: Please don't do this in the setup. MSI is very complex with impersonation and runtime behavior - which is what causes the mysterious error messages you see. There is absolutely no reason to do this in the setup if it can be done with user rights in the application launch sequence. You simply rename the folder on launch of the application, that should do it? Application launch code is much easier to implement and spectacularly easier to debug than custom actions (especially deferred mode custom actions). You can also provide interactive error messages if need be (as opposed to errors written into a log - or no log at all).
Implementation: Obviously beware of introducing application launch code bugs by perhaps setting a flag in the registry once rename is complete for the user in question - in order to disable this rename operation from running more than once. Roaming profiles could cause problems, make sure you set the operation to run once per machine - at least. You could also write the flag into the non-roaming section of the appdata folder hierarchy? That is probably better. Certainly in fact. Should trigger no roaming issues.
Challenges: Just a couple of challenges:
Locks?
Would there be any file / folder locks on application launch? Maybe? Catch the exception, inform the user, shutdown and retry? Refuse to launch until rename can happen? Acceptable?Old application launch?
: Is this important? Some people try symbolic links - my two cents - they are the devil's work :-). I guess the question is, what happens if the old application does not find its files? Does it even launch? Second question is: does it matter at all that the old application does not work properly after the "cleanup"?