remove stream redirection logs from APPDIR on uninstall - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

toddpatt
Posts: 111
Joined: Fri Jan 08, 2010 1:36 am

remove stream redirection logs from APPDIR on uninstall

Hello AI Support Team,

I'm using AI v7.3.1 and having a problem removing stdout and stderr logs written-to by my java application. I've searched the forum and seen several related posts, which I've read carefully:
- Removing Log folders at the time of uninstall
- Files and Folders are not deleted after uninstall
- Remove the installed directory completly on Uninstall

I've also carefully read the folder removal dialog documentation.

I apologize for asking a question already asked by several other AI users, but I simply cannot figure-out a solution. Here is my configuration:

Project Type = Java

Project Definition > Java Products > "Virtual Machine" tab
- selected both "Stream Redirection" checkboxes
- edited the default path from "[APPDIR]output.log" to "[APPDIR]logs\output.log"
- edited the default path from "[APPDIR]error.log" to "[APPDIR]logs\error.log"

Project Definition > Files and Folders
- select "Application Folder" from the tree, rt-click and choose "New Folder" > Regular
- name the new sub-folder "logs"
- select the new "logs" folder, rt-click and choose "Properties"
- ensure the "Create folder on target machine" checkbox is selected but disabled (I don't know why the checkbox is disabled, but that is the behavior)

*** Test 1 ***
- build the package (single MSI) and install
- launch the app, which successfully writes to [APPDIR]logs\output.log
- shutdown the app
- uninstall the app
- the logs in [APPDIR]logs are not removed
***************


Project Definition > Files and Folders
- select the "logs" folder, rt-click and choose "Uninstall Cleanup..." which launches the wizard
- on the "Files and Folders" screen:
** Parent folder = APPDIR\logs
** choose radiobutton "Delete folder and all its contents (files and subfolders)"
** associate it with the native java launcher component (the EXE)
- on the "User Interface" screen:
** choose radiobutton "Always perform cleanup without prompting the user"
** checkbox "Do not perform cleanup when just upgrading" is selected by default
- when the wizard is finished, rt-click the "logs" folder, select "Properties", select "Remove" tab and verify the new settings:
** checkbox "Remove folder" should be selected
** Operation = Always remove folder (even if it is not empty)
** Component = associated to the native java launcher EXE
** Remove On = Component uninstall
** Condition = (AI_CLEAN_RESOURCES_UNINSTALL = "1") AND (NOT UPGRADINGPRODUCTCODE)
- go back to the "Properties" tab
- as part of the Uninstall Cleanup Wizard, the checkbox "Create folder on target machine" was unselected / unchecked - reselect it

*** Test 2 ***
- delete any build cache
- build the package (single MSI) and install
- launch the app, which successfully writes to [APPDIR]logs\output.log
- shutdown the app
- uninstall the app
- the [APPDIR]logs folder and all its contents are now removed during uninstall, but now the [APPDIR] root folder is not removed
***************


Project Definition > Files and Folders
- select the "Application Folder" folder, rt-click and choose "Uninstall Cleanup..." which launches the wizard
- repeat the same process as described for the "logs" folder
- when finished with the wizard, rt-click the folder and reselect the "Create folder on target machine"

*** Test 3 ***
- delete any build cache
- build the package (single MSI) and install
- launch the app, which successfully writes to [APPDIR]logs\output.log
- shutdown the app
- uninstall the app
- the [APPDIR]logs folder and all its contents are removed during uninstall, the [APPDIR] root folder is now removed, but the parent folder of [APPDIR] is not removed (e.g. C:\Program Files\MyCompany)
***************


Hopefully the pattern I've described is clear... I just want to redirect the stderr and stdout streams from my java app to a "logs" subfolder, and then delete that subfolder (along with "C:\Program Files\MyCompany\MyApp)" when uninstalling.

I am running the generated MSI on Windows XP, SP3 which has Windows Installer v3.01.4001.5512

Perhaps this is a bug? Or do I need to have some additional properties set/configured in my AI project? Thanks for any help you can offer.
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: remove stream redirection logs from APPDIR on uninstall

Hello,

You can only delete the logs by using a .bat file if you want to remove the parent folder properly.
You will need to place that custom action before the RemoveFiles standard action, so that the folder is removed.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
toddpatt
Posts: 111
Joined: Fri Jan 08, 2010 1:36 am

Re: remove stream redirection logs from APPDIR on uninstall

Hi Gabriel,

Thank you for your quick reply, I appreciate it! I do have some follow-up questions, though.

(1) Should the .bat file delete just the log files (output.log and error.log) or should it delete the log files and the "logs" folder?
(2) If I use the .bat file, does that mean I should remove / undo the properties I added with the Uninstall Cleanup Wizard?
(3) Are the stream redirection logs a special case? I'm confused why I need to do this with a .bat file, since in the other posts (please refer to the links I provided in my original post), AI users were told to use the new "Uninstall Cleanup Wizard".

Thanks for your help,
-Todd
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: remove stream redirection logs from APPDIR on uninstall

Hello,

I accidentally overlooked the fact that this does not necessarily need to be done using bat files. You can use two File Removal Operations. One on the files in the log folder. Use the "*" wildcard to remove all of them. The other will be used to delete the logs folder.

However if you choose to use the bat:
(1) Should the .bat file delete just the log files (output.log and error.log) or should it delete the log files and the "logs" folder?
It should also remove the logs folder if the folder was created by your application and not by Windows Installer
(2) If I use the .bat file, does that mean I should remove / undo the properties I added with the Uninstall Cleanup Wizard?
Yes, the Uninstall Cleanup Wizard should not be used.
(3) Are the stream redirection logs a special case? I'm confused why I need to do this with a .bat file, since in the other posts (please refer to the links I provided in my original post), AI users were told to use the new "Uninstall Cleanup Wizard".
This is because the cleanup wizard executes too late, removes the files, but leaves the parent folder unremoved. This is because there is no one left to do the actual folder deleting, it has already been done by Windows Installer earlier. We will make an improvement that will allow the Uninstall Cleanup Wizard to be used in cases such as yours. The improvement will be available in a future version of Advanced Installer.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
toddpatt
Posts: 111
Joined: Fri Jan 08, 2010 1:36 am

Re: remove stream redirection logs from APPDIR on uninstall

Hi Gabriel,

I used the File Removal Dialog to create two File Removal operations, as you suggested. This approach works well (using AI v7.5 now) - thanks very much for the help.

Return to “Common Problems”