cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mumbles
Level 7

Deleting unused files at end of Installation.

Hello All,

I have what should be a basic question... We have a complex logic structure to remove unused files based on how an xml file is generated. But basically we want to remove unused files. So since this logic is quite complex, i put it into a c# console application.

I call in the deferred in system context custom action, exe type, installed with product. (I'm using a basic MSI project).

When i call the exe, no files are deleted. However, when the installation is completed, and i double click the exe console app, the files are being deleted, no problem.

Is this because the installer has a hold on the files until the installation is 100% complete? I can't quite figure out what is going on. I've tried calling it in the Deferred sequence, Deferred in System Context.

Please advise.

TIA
Labels (1)
0 Kudos
(5) Replies
TsungH
Level 12

In your custom action, I would verify if the XML file exists at the time of execution. In addition, you will have to make a determination if the files are in use, and if so, by what.
0 Kudos
mumbles
Level 7

The file is present during execution. So there is nothing going on there.
0 Kudos
phill_mn
Level 7

I would add a CA right before the CA for the exe which opens a modal message box (just for testing, to pause the installer) or you could use a tool like catest (Google) which is very helpful. With the installer paused, check the file access with a tool like ProcessMon (Microsoft Sysinternals) or launch the exe and debug from the same deferred user context as the installer is using, using run as.
0 Kudos
mumbles
Level 7

What is catest?

Fantastic idea on the pausing, never thought of that before, thanks!
0 Kudos
phill_mn
Level 7

catest.dll is a tool I used to debug a C++ custom action. The readme that comes with it only talks about launching another CA DLL, so you might need to tell it to launch a wrapper DLL which then launches your exe for test purposes. You add catest's CA to your MSI where you would have added the CA you want to debug. Then in a INI file you provide the details for your CA. When MSI runs to that point it launches the CA in catest.dll which opens a dialog box and allows you to attach a debugger or setup your test scenario. But the really useful feature is that when you complete your custom action (successfully or failure and implement a change in your CA) you can just have the catest dialog launch your CA again, without having to rollback and start the MSI again. It has been several months since I last worked with it, so I hope I recalled the details correctly.

More details here:
http://blogs.msdn.com/b/astebner/archive/2005/03/07/388739.aspx

download the zip here:
https://skydrive.live.com/?cid=27e6a35d1a492af7&id=27E6A35D1A492AF7%21483
0 Kudos