DiegoCP
Posts: 139
Joined: Fri Jan 23, 2015 1:02 pm

Remove Specific Files During Uninstall

Fri May 05, 2017 11:01 am

Hello,

I have a few files i need to ask the user during Uninstall if they want to remove them.

The issue is these files are created by my application in a different location.

Let's say i install for all users:

C:/ProgramFiles (x86)/MyApp

and inside i have some files.

But there is a database the is generated by my application inside

C:/ProgramData/MyApp/database/db.sqllite

Now during uninstall i need to ask the user if he wants to uninstall this file.

I do this by adding a checkbox before the remove Dialog.

How can i make sure this file is removed is checkbox is checked, considering this path is not the application path??

Thank You for Help!


Best Regards,
Diego.

mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Remove Specific Files During Uninstall

Fri May 05, 2017 2:30 pm

Hello Diego,

For conditionally deleting files created post-install and located in your ProgramData folder, you should create a new file removal operation conditioned by a property value.

These are the steps for achieving this:

1. Go to "Dialogs" page in your project. Select for example MaintainanceWellcomeDlg and create a new checkbox - "Remove database file during uninstall". For this checkbox set property name "REMOVE_FILE". Enter "Yes" in the checkbox value.

2. Go to "Files and Folders" page and select Common Application Data. Create a new folder "database". Create a sub folder "db.sqllite".

3. In db.sqllite folder create a new "File Operation - Remove file". Enter the name of the file you want to remove and select "Remove on: Component Uninstall". Enter " REMOVE_FILES="Yes" " in the condition field.

Regards,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

DiegoCP
Posts: 139
Joined: Fri Jan 23, 2015 1:02 pm

Re: Remove Specific Files During Uninstall

Fri May 05, 2017 6:16 pm

Hello mihai,

Thank for your help!

This solves the removing file part.

I'm sorry i should have described more the issue.

there are different paths if it was installed for allusers or not for example:

C:/ProgramData/MyApp/database

if for currentUser for example:

C:/ProgramData/MyApp/Diego/database

how can i filters this during uninstall.

Thank you again for your support!


Best Regards,
Diego.

Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Remove Specific Files During Uninstall

Mon May 08, 2017 1:08 pm

Hello,

First of all, I noticed that you use "/" instead if "\" in your path. Please note that "Common Application Data" from files and folders has two possible locations on disk, depending on the "Installation Type" setting from "Install Parameters" page. For example, on Windows 10, Per-machine install: "C:\ProgramData\" , Per-User install: "C:\Users\%username%\AppData\Roaming".

If you need to delete a file that is located either in the machine location or the user location, you should create two property based folders and a file removal operation in each one of them.

This is the complete method:

-go to "Install Parameters" and create two new properties. Name them for example MPD_PATH (machine program data path) and UPD_PATH (user program data path).For each one of them enter "c:\" value
- go to "Custom Actions" page and create two "Set installer property" custom actions with sequence after Searches in install execution stage. The first one should set MPD_PATH to "[%SystemDrive]\ProgramData\MyApp\Database". The second custom action must set UPD_PATH to "[%SystemDrive]\Users\[%USERNAME]\AppData\Roaming\MyApp\Database"
-go to Files and Folders tab and create two property based folders, one for MPD_PATH and the other for UPD_PATH. In each of these folders create a new file removal operation for your file.

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

DiegoCP
Posts: 139
Joined: Fri Jan 23, 2015 1:02 pm

Re: Remove Specific Files During Uninstall

Mon May 08, 2017 3:09 pm

Hello Sorin,

Thank You for your Help!

I will try this!


Best Regards,
Diego.

Sorin
Posts: 663
Joined: Mon May 08, 2017 1:03 pm

Re: Remove Specific Files During Uninstall

Mon May 08, 2017 3:12 pm

You are welcome!

Best regards,
Sorin
Sorin Stefan - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”