PDA

View Full Version : Clean up and setup.exe icon issues.



david.luo
07-21-2008, 11:39 PM
Hello there:

I'm using InstallShield 2009 basic MSI project.
Q1:
I found out in many documents said that if I want to delete any files created by my application, I need to put the target names in the "RemoveFile" table in Direct Editor. I wonder how I can just delete all the files in the installDir after uninstallation for I even don't know what files will be created by my application. Maybe they're some log files or something.


Q2:
I can change the setup.exe file's icon in InstallShield 2009 InstallScript project. But this can not be done in basic MSI project. Can anyone tell me why the basic MSI project does not support this function and how to make it happen?

Q3:
The InstallShield 2009 support multi-instance maintenance. If I add my files using dynamic links, how can I change the behavior that let "Repair" work always overwrite the target files regardless their versions or date? I know that if I add files using component wizard, I can change every files' properties to set the "always overwrite" attribute. But it seems there's no such properties when I use dynamic links to add my files.

nikhilgupta
07-21-2008, 11:54 PM
for your first question, you can use wild card to remove files. specifying *.* in target name will remove all files in the specified directory.

david.luo
07-22-2008, 12:32 AM
for your first question, you can use wild card to remove files. specifying *.* in target name will remove all files in the specified directory.

Thank you nikhigupta.

I've tried this wild card before. But it seems that this operation can not run interatively.
In "FileName" column I filled in "*.*" and in "DirProperty" column I filled in "INSTALLDIR", and the "InstallMode" column I filled in "2". I used this row to delete all the files in the install directory after uninstallation. But it still leave some files created by my application in some subdirectories.
For some subdirectories will be created as well as some log files, I still can't know which directories to be specified.

david.luo
07-22-2008, 01:29 AM
Could anyone be kindly enough to advise me for the three questions? Thank you~

david.luo
07-22-2008, 03:31 AM
There are some help doc in InstallShield help library title with "Removing Files that Were Created by Your Product" saying that:
"By default, files created by your product after the installation is complete are assumed to be user data, and are not removed when the user uninstalls your application. "

"Records you create in the RemoveFile table (using Direct Editor) can specify additional files to remove. For example, if your application creates a file called Product.ini inside INSTALLDIR and you want the file removed when the component containing your main executable is removed, add a record with the following contents to the RemoveFile table:

Additions to Add to the RemoveFile Table
FileKey
remove_file

Component_
ProgramFiles

FileName
Product.ini

DirProperty
INSTALLDIR

InstallMode
2
"


So, is it true that I need to know anywhere in my application that will produce files and record each one of the folders into the "RemoveFile" table and fill the corresponding "FileName" column to "*.*" to clean my installation folder?

Can't I just point out the folder name and ask the InstallShield delete all the files in this folder including the ones in the subdirectories?

joshstechnij
07-22-2008, 12:58 PM
You can enter a wildcard pattern for the FileName column to remove files matching the wildcard with the RemoveFile table. An additional row would be necessary for each subfolder contained in the parent/root folder to remove files from the subfolders. If the column is left blank, the folder will be removed if no files or subfolders exist in the folder specified. Using the DeleteDir function from an InstallScript custom action may provide a simpler solution than the RemoveFile table.

Regarding the other questions, changing the setup.exe icon is not possible with any MSI based project. You could change the icon on the template setup.exe's in the Redist\Language Independent\i386 folder with a resource editor, but this will affect all projects built with InstallShield on that machine.

For files dynamically linked to a project, the always overwrite option is not supported (mainly because this option changes file information for files contained in the project; dynamic files are not technically contained in the project). You could post-process the MSI file after build to change the versions on files in the File table to 65535.0.0.0 if needed. The REINSTALLMODE property value could also be changed to 'amus' to have Windows Installer ignore file versioning rules. Note that neither of these methods are recommended for use in a production installation as both will almost certainly cause Windows Installer auto-repair and prompts for source in undesired scenarios.

david.luo
07-22-2008, 09:16 PM
You can enter a wildcard pattern for the FileName column to remove files matching the wildcard with the RemoveFile table. An additional row would be necessary for each subfolder contained in the parent/root folder to remove files from the subfolders. If the column is left blank, the folder will be removed if no files or subfolders exist in the folder specified. Using the DeleteDir function from an InstallScript custom action may provide a simpler solution than the RemoveFile table.

Regarding the other questions, changing the setup.exe icon is not possible with any MSI based project. You could change the icon on the template setup.exe's in the Redist\Language Independent\i386 folder with a resource editor, but this will affect all projects built with InstallShield on that machine.

For files dynamically linked to a project, the always overwrite option is not supported (mainly because this option changes file information for files contained in the project; dynamic files are not technically contained in the project). You could post-process the MSI file after build to change the versions on files in the File table to 65535.0.0.0 if needed. The REINSTALLMODE property value could also be changed to 'amus' to have Windows Installer ignore file versioning rules. Note that neither of these methods are recommended for use in a production installation as both will almost certainly cause Windows Installer auto-repair and prompts for source in undesired scenarios.

Thank you joshstechnij, these are really help.

david.luo
07-24-2008, 01:31 AM
Hi joshstechnij,

I have one more question.

I tried your suggestion to write a installScript function to do the clean up job using API "DeleteDir". And I read the document that if I just want to run this script during uninstallation, some condition must be met like "if MAINTENANCE then ".
Below is my function code:

#include "ifx.h"

// The keyword export identifies MyFunction() as an entry-point function.
// The argument it accepts must be a handle to the Installer database.
export prototype DeleteAll(HWND);

function DeleteAll(hMSI)
NUMBER nBufferSize;
STRING installDir;
begin
if MAINTENANCE then
MessageBox("Now start to delete!",INFORMATION);
nBufferSize = MAX_PATH + 1;
MsiGetProperty(hMSI, "INSTALLDIR", installDir, nBufferSize);
if(DeleteDir(installDir,ROOT)=0) then
MessageBox(installDir+"was deleted.",INFORMATION);
else
MessageBox("Can not delete the "+installDir,SEVERE);
endif;
else
MessageBox("Sorry, it's not the uninstall time.",INFORMATION);
endif;

end;


And I created a custom action to run this script function and put it after the "InstallFiles" action in the execution sequence.

I found out that this function would run in both installation and uninstallation. And the condition "if MAINTENANCE" was always false. If I removed this condition, this function would be executed in both the installation and uninstallation and tell me it can not delete the install directory .


Is there something I need to change in my code or this custom action should after some specific action to make it work?

I want to delete all the files in my installDir during uninstallation using MSI project. How can I do this using install scripts and custom action?

joshstechnij
07-24-2008, 10:23 AM
I would recommend setting a condition on the custom action such as:
REMOVE~="ALL"

This should only allow the action to run during a full product uninstall.

david.luo
07-27-2008, 08:56 PM
Still, there are always something left behind. It seems that these files are read only or created by applications.


Can anyone tell me just how to rudely delete the whole installDir directory no matter there are read only files or files created or modified by application or customers using basic MSI project.

I want to delete a whole directory including alll the files and subdirectories, can InstallShield support this?

Urgency, need help!

joshstechnij
07-28-2008, 11:07 AM
The DeleteDir function does not remove files that are read-only. If you need to remove these files, you could try clearing the read-only attribute on any files necessary with SetFileInfo and then call DeleteDir. (Note that the Windows API DeleteFile will also not delete read-only files.)