Showing results for 
Show  only  | Search instead for 
Did you mean: 

Retain old configuration files after new installation if old configuration found

Retain old configuration files after new installation if old configuration found


This article will helps you to understand to keep and replace the old configuration after new installation if old configuration found


1. Add show message dialog box and add the message which you want to display to the customer.
2. Put a rule on Message box to check whether the version you are checking is already installed or not,
rules > add rule > Check File/Folder Attributes >In File/Folder path, mention the file/folder where the older version installed.
3. Create a jar out of the code below and add an Execute custom code then add the jar and the class name

import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.Date;

public class OldConfig {

public static void main(String[] args) {
// Define the paths for the old and new configuration files
String oldConfigFilePath = "path/to/old/config/file.txt";
String newConfigFilePath = "path/to/new/config/file.txt";

// Check if the old configuration file exists
File oldConfigFile = new File(oldConfigFilePath);
if (oldConfigFile.exists()) {
// Backup the old configuration file (e.g., by appending a timestamp)
String timestamp = new Date().toString().replace(" ", "_").replace(":", "");
String backupFilePath = "path/to/backup/config/file_" + timestamp + ".txt";

try {
// Copy the old configuration file to the backup location
Files.copy(oldConfigFile.toPath(), new File(backupFilePath).toPath(), StandardCopyOption.REPLACE_EXISTING);
System.out.println("Old configuration file backed up to: " + backupFilePath);

// Optionally, you can delete the old configuration file if needed
// oldConfigFile.delete();
} catch (IOException e) {


4. Build and run the Installer.

Labels (4)
Was this article helpful? Yes No
No ratings
Version history
Last update:
‎Dec 07, 2023 02:43 AM
Updated by: