Basic MSI installer not replacing deleted files on re install - installation

I can be missing something very simple but for some reason on reinstall my basic MSI installer (Installshield 2009) is not writing deleted files from the installed directory, it write the entire component files if I delete the key file of that component but I delete non key files are not written on reinstall.
I tried setting uninstall custom action before install but that didnt work, I am currently using delete all files custom action triggering after browse dialog location is set which look ugly.
I am sure there is a simple way of achieving what I want.

On "reinstall" or "repair", I would not expect any files to be deleted. The purpose is to bring back the installation to the original status.
With components and a repair: if you have multiple files in a component, unless the keyfile is deleted, a repair will not restore the other files. Best practice is to have one file per component, and have that file be the key path for that component.
I would avoid any sort of "delete all files" custom action as well. If you have files you want to remove on uninstall, look into using the RemoveFile table.
edited to add: if you have files that are not installed by the installer, but instead some how artifacts of the program itself. There is no need to use the RemoveFile table or custom actions to delete files installed by the MSI itself.

Related

Installshield problem setting file permissions

in InstallShield 2011, I cannot modify file permissions under Application Data -> Files and Folders. Whenever I right click on items, it shows grayed out menu buttons. I can't even delete existing entries.
In a bat script later in the installer, I can't copy over certain files because I don't have the right permissions so the installer fails when trying to reference files in BackupFiles. For some reason all the other files get copied over just fine; I can't modify those file's permissions either. I read online that you have to click the "Properties" button in that context menu to change permissions.
My version is InstallShield 2011 Premiere Edition Version 17.
I don't understand why this is grayed out. The source files do not have any restrictions on them so it must be the installer doing something related to permissions.
That boxy orange overlay on the folders and files indicates that these are coming from a Dynamic File Link. Because these files aren't actually added to your project, not all configuration options are available. You might have to edit the permissions on the source files (before build), or change your project to statically include all or some of these files. Given the size of that tree, changing it all to static could be a bit tedious. Changing parts of it (by editing the link exclusions) might be a good middle ground.
Or you could better determine what's going wrong and see if you can address it in the batch file. Assuming this is InstallScript (rather than InstallScript MSI), the entire setup along with any processes it launches should be elevated. So I'm having a hard time guessing what could go wrong. Perhaps a read-only flag? Perhaps use a tool like process monitor to get more information on that, and see if you can add a call to attrib -r, or cacls, or whatever.

visual studio 2010 setup project - uninstall custom action

During install, I'm passing some CustomActionData to CustomAction.
Is that data stored somehow? I need to use some of the data during uninstall in uninstall custom action.
I can't resend this data because user might not be using the msi file to uninstall but go to add / remove programs.
I need somehow in uninstall custom action to retrieve data that was already sent during install.
Here is the usual approach:
save the information you need in an installer property
use that property as a registry entry value
create a search (in Launch Conditions Editor) which reads this registry entry
the search property can be used during uninstall
Basically, you save the information during install and read it through a search during uninstall.

Add an option to either remove or keep installed files on uninstall?

I'm using the Visual Studio Setup Project to create my installer.
How can I give the user an option to either keep or remove files and/or a folder when uninstalling? The install includes a database and the may want to keep this on disk and associated content in case they re-install or upgrade.
you could add a custom uninstaller System.Configuration.Install.Installer that will ask for the choice and then removes the files depending on the result or even better add a wizard page with a radio button to ask for the decicion and pass the selected button value to your install helper as arguments. See InstallHelper samples how you can pass these option values to your own helper class.

How to setup Installer project with conditional file copying

I am building a VS 2010 installer, and I want to copy files to app folder depending on what options I select in UI (UI is not simple, so the only option is to show custom dialogs in Install custom action).
The problem is that custom action is actually executed after files are copied already.
One possible solution I can think of is to install all these files into the app dir, and then delete some unnesessary files in custom action. But these files are "secure" in some way, so I don't want to copy them to filesystem, even for a short period of time.
Any thoughts?
If your files shouldn't ever be on the filesystem, you have a problem in the requirements. The .msi storage itself is an open format and can be read by many tools, so if someone knows the file it's possible for them to find and extract it manually.
I agree that it's better to avoid deleting the files after they've been installed for two reasons. One: it avoids wasted work, and two: it won't cause repair scenarios due to missing files that Windows Installer thinks should be present. You should probably figure out how to determine whether these files should be present at an earlier stage of the installation, and set properties that cause this to happen (disable components by condition, or change feature states).
Most controls in MSI dialogs use installer properties. For example, a checkbox may use a property named MY_CHECKBOX which is set to a value or it's empty, based on whether the checkbox is checked or not.
These properties can be used to condition files:
select your setup project in Solution Explorer
click File System Editor button from Solution Explorer top pane
select the file you want to condition
in its Properties pane set Condition field to the condition you want, for example
MY_CHECKBOX = "value"

Visual Studio Setup Project - conditionally install file

I have a VS 2008 Setup project. I only want to install an XML file if it does not already exist on the target system. The installer overwrite rules for non versioned files ensure that a file will never be overwritten if it has not been modified on the target system. But I want to never overwrite the file. There is a Condition property that can be set on a file in the Visual Studio installer properties for a file. What is the correct syntax for the Condition property to check for existence of file and only install if it is not there?
You will need to go to the Launch Conditions tab and search the target computer for the file you want to check for. The launch condition will let you specify the name of a property it will set to the path of the file if it exists, otherwise it will be empty. You can now use this property as the condition on your file.
I was able to use a launch condition to set a property, and use this for a conditional install of a file, so I will mark 'heavyd' as the correct answer. However, was not able to use the file search effectively, as was suggested (see comments on the answer). Instead, I used a Windows Installer Search (one of the three types of searches available in a VS 2008 Setup Project) with the MSI ComponentID, as follows (I found the technique here):
Product 1 is installed and has a file named MyFile.txt.
You use ORCA (from the Windows Installer SDK) to view the File table, and find the row that represents MyFile.txt.
You get the value of the Component_ column and then open the Component Table.
In the Component Table you find the row that has the Component_ value in the Component column, and get the ComponentID. Copy this value into clipboard. Close ORCA.
In your setup project, open the Launch Conditions Editor and add a Windows Installer Component Search. For the ComponentID property of the new search, paste the ComponentID.
Copy the Property property. It should be something like COMPONENTEXISTS1.
Open the File System Editor and select the Application Folder, then select the file you want to conditionally install.
Edit the Condition property to be COMPONENTEXISTS1 = FALSE.
Set the Transitive property to true if you want the condition to be evaluated each time the installer is run (not just the first time).
Now, MyFile.txt will only be installed if it is not already there.
There is one caveat with this technique: Doing a repair on the installation will cause the file to be deleted, even though the file is marked as Permanent! Not good. I worked around this by adding some custom actions (calling vbscript files) to backup and restore my file.
What a hassle to just achieve so simple a task: install a file once on initial install, then, never again overwrite it.
If anyone has a better solution, I am all ears.

Resources