How to install a user specific file
The following article uses options that are available starting with the Professional edition and project type.
Sometimes an installation package may need to install a file which is specific to each user. For example, this file can be a license file which is generated automatically when the user downloads the installation package or it can be distributed with the MSI.
Since Windows Installer handles only the files inside the MSI package and the external file can be changed at any time, the user specific file must not be included in the package. In this case, the file will be placed next to the MSI (or EXE) installation package and it will be accessed by using the SOURCEDIR (or SETUPEXEDIR) property.
In order to install the external file on the target machine, you can follow these steps:
- Configure your Advanced Installer project to install your application
- Make sure that you don't include the external file into the project
- Go to the Install Parameters page and create the SOURCEDIR property
- Set its value to C:\ (this property will be resolved at run-time to the path of the folder which contains the MSI package)
- Go to the Files and Folders page and create a property-based folder by using SOURCEDIR
- Select the "Application Folder" directory
- Use the "New File Operation" button on the toolbar to create a "File Copy/Move" operation in it
- Set the Name field in the Source File section to the name of the external file
- Set the Folder field in the Source File section to SOURCEDIR
If your installation package uses an EXE bootstrapper, you can use the SETUPEXEDIR property instead of SOURCEDIR.
- Set the Name field in the Destination File section to the name you want for the external file after it has been installed
- Set the Component combo in the Properties section to a component which is always installed
- Set the Operation combo in the Properties section to Copy
- Build the setup package and make sure the file is placed alongside it at install time
This file operation will copy the external file into the installation folder. It doesn't matter what this file contains (it can be modified anytime) as long as it has the name used by the file operation.
Since this file is not inside the MSI package, an uninstall will not remove it automatically. If you want to remove this file when the package is uninstalled, you can use one of the approaches explained in the Remove a file or a folder during installation How-To.
If the package is installed from a network location, that location should also be available during the upgrade/uninstall, otherwise the process will fail. In order to avoid this, you can go to the SOURCEDIR/SETUPEXEDIR folder's related component from the Organization page and set the Do not register this component with Windows Installer option for it.