Replace string in text file

About

This is custom created predefined action by Master Packager team that can find and replace text in file.

It’s useful when you need to adjust configuration files during installation, such as changing paths, server names, connection strings, or other values stored in text files. The action operates under SYSTEM context during installation, so it requires permission to modify the target file location.

Master Packager Advanced Editor - Predefined Custom Actions - Replace string in text file

Note: This action works only with text-based files (for example, .ini, .xml, .json, or plain text configuration files). It does not support binary file editing.

How to use it?

  1. Open MSI/MST with Master Packager

  2. Click on Custom Actions in left menu

  3. Click on Predefined Actions tab

  4. Click “Add New Predefined Action” and choose “Replace string in text file”

  5. Add the path by clicking three dots (…) to locate the target file where text changes are needed.

  6. In the Find what field, enter the text value you want to search for.

  7. In the Replace with field, enter the new value that should replace the target text.

  8. Select the target file’s encoding (e.g. UTF-8, ANSI) to ensure the action executes correctly.

Note: Always ensure you select the correct file encoding (e.g. UTF-8, ANSI). Using the wrong encoding could corrupt the file
contents.

  1. Enable Regex Disabled if you do not want to use regular expressions, meaning your search is for exact text matches only.
  2. Enable Non case sensitive if the search should not be case-sensitive.

Tip: Always back up files and confirm encoding to avoid corrupting important configuration files.