cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Ivan_mysammy
Level 4

How to remove files and folders created by application during uninstall

Hi,

I have searched through the threads in this community, but still didn't find what I want. I guess there should be a very simple method to remove the files not created by the installer during uninstall, cuz this is a very common senario. Can anyone give me some idea?

Thanks,
Labels (1)
0 Kudos
6 Replies
Rouslan
Level 4

1) You can use RemoveFile table if you know name of file to delete.
(See msi help or MSDN)
2) Also you can use custom action.
0 Kudos
Ivan_mysammy
Level 4

Rouslan wrote:
1) You can use RemoveFile table if you know name of file to delete.
(See msi help or MSDN)
2) Also you can use custom action.


Thanks for your reply, Rouslan.
It looks like installscript custom action works for my senario. I will try these two method and post my results later
0 Kudos
Ivan_mysammy
Level 4

Rouslan wrote:
1) You can use RemoveFile table if you know name of file to delete.
(See msi help or MSDN)
2) Also you can use custom action.


Rouslan, for the first method, how to set "Component" field in RemoveFile table? The file to be removed is not associated with any component, but generated by the application. Thanks
0 Kudos
Ivan_mysammy
Level 4

Here's my solution:

senario: delete INSTALLDIR folder, all its subfolder and files during uninstallation

steps:

1. create an Installscript function:

#include "Ifx.h"
export prototype Fn_DeleteDir(HWND);
function Fn_DeleteDir(hMSI)
STRING strInstallDir;
NUMBER nSize;
begin
nSize = 256;
MsiGetProperty(hMSI,"INSTALLDIR",strInstallDir,nSize);
DeleteDir (strInstallDir, ALLCONTENTS);
end;

2. create a custom action to call above function, settings:

Function Name: Fn_DeleteDir
Return Processing: Synchronous
In-Script Execution: Immediate Execution
Execution Scheduling: Always execute
Install Exec Sequence: After InstallFinalize
Install Exec Condition: REMOVE = "ALL"

leave other settings by default

end steps.

My installscript code is not strong enough and I am not sure the custom action settings are appropriate, anyway it works as I expect.

reference:
http://community.flexerasoftware.com/showthread.php?t=193676&highlight=remove+files
0 Kudos
Rouslan
Level 4

Ivan_mysammy wrote:
Rouslan, for the first method, how to set "Component" field in RemoveFile table? The file to be removed is not associated with any component, but generated by the application. Thanks

You can set any component. For examle:
FileKey: MyRandomKey123 (any uniq key for RemoveFile table)
Component_: MyExistingComponent (any existing component)
FileName: myFileToDelete.tmp (exact file name)
DirProperty: MYDIRECTORY (directory key from Directory table for your file location)
InstallMode: 2 (Remove only when the associated component (MyExistingComponent) is being removed)
0 Kudos
Ivan_mysammy
Level 4

Rouslan wrote:
You can set any component. For examle:
FileKey: MyRandomKey123 (any uniq key for RemoveFile table)
Component_: MyExistingComponent (any existing component)
FileName: myFileToDelete.tmp (exact file name)
DirProperty: MYDIRECTORY (directory key from Directory table for your file location)
InstallMode: 2 (Remove only when the associated component (MyExistingComponent) is being removed)


Thanks Rouslan, your method works!
0 Kudos