Previous installation of my product was done in Visual Studio 2008 as deployment project (vdproj). User had the option to install per user (just me) or per machine (everyone). I’m doing new installation in WiX, and if product was installed per machine then new installation will uninstall previous version. BUT, if product was installed per user in %ProgramFiles% then new installation will not uninstall previous, making a mess of two installations in the same folder.
I want to detect and stop the installation in this situation. No automatic uninstall, just detect and stop. The solution should handle the case if one user did previous per user installation, and another user is doing new per machine. I thought DirectorySearch and FileSearch elements could be used, but they run before target folder is determined in UI.
If WiX code is involved please provide small example. I’ll learn from it.
EDIT: If I add a property using AppSearch features DirectorySearch and FileSearch, and then check a condition with Condition element this would check the condition at installation startup. This is not what I want. The user may change the target folder, so I need to check the existence of files in target folder in some step after the target folder can no longer be changed.
In my naivety I also tried to read the value of property mentioned in previous paragraph with SetProperty in some custom action, but that does not work either. The value is read alright, but it’s the value that was determined at the start of setup.
Proper solution should probably include the answer given to another question. I’m currently toying with JScript, as per tip given in WiX tricks community wiki. Will probably make it a .dll to avoid anti-virus meddling, mentioned in Rob Mensching’s blog post.
Here’s how I’ve done it in the end. I’m calling custom action queued after
RemoveExistingProducts:After this point old installation is removed if possible, so if there are files remaining in target folder then something’s wrong. This moment happens rather late, but I don’t know of a way to detect if existing files are going to be uninstalled. Code in custom action just checks if target folder exists and is not empty, and if so calls it quits (
ExitOnFailureerror handling removed for brevity):