visual studio 2010 setup project - uninstall custom action - visual-studio-2010

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.

Related

Basic MSI installer not replacing deleted files on re install

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.

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.

Visual Studio 2010 update registry in setup application

I've recently created an application for my brother to use, it has several entries stored in the registry that it uses. I created a Setup Application in VS2010 so he can install the application to his PC with ease and set the entries to some default values for him, which he has changed. e.g.
I have a entry called "SummaryFolder" and the value of "Successfully Installed" - so when it was installed it would have the default value. He will have changed this by now to an actual folder on his PC.
Now I've just made a change to the program and added a couple more registry entries, modified the setup application and added in the new entries for installing. I've changed the build number of the setup app, so when he installs the app, it actually UPDATES his existing version. The problem I'm having is that the existing registry entries he has from the initial installation has been overwritten with the default "Successfully Installed" values, hence removing the folder he set.
So my question is: How can I specify for the setup program to only add the registry entries if they DON'T already exist ??? I want to have the installer to be as simple as possible for him.
Many thanks for any help.
You can try this approach:
select your setup project in Solution Explorer
click Launch Conditions editor button at the top of Solution Explorer
add a new registry search and configure it to search for your registry entry
set the search property to something meaningful, for example SUMMARY_FOLDER_REG (only uppercase letters so its a public property)
in the Registry Editor select your registry value
in its Properties pane set the Condition field to the negated search property:
NOT SUMMARY_FOLDER_REG
This way the registry entry is installed only if the search doesn't find anything.

Run two executable after Installation is complete

I am making an Installer using VS Setup project(using VS 2010). Everything is fine except that when I am trying to run two executable file in "Committed" event of the installer they are running before Finish/Close button of Installer is clicked.
I want these executable files to run after I have clicked Close/Finish button of the installer. i.e. whole installation is completed.
Is there any way to accomplish this??
Thanks in advance
This is the normal behavior. Commit actions run as part of InstallExecuteSequence, so before the finish dialog is displayed.
If you want to execute an action when pressing Finish, you need to use control events:
modify your MSI so the custom actions are not used by InstallUISequence or InstallExecuteSequence tables
for the Finish button create a published DoAction control event for each custom action
This is not supported by Visual Studio. So you can either try modifying your generated MSI with Orca or use another setup authoring tool which supports it.

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