Skip to main content

Replace String in Text File

Use this predefined action to find and replace text in a file during installation.

It is useful when you need to update configuration values such as paths, server names, or connection strings.

Master Packager Advanced Editor - Predefined Custom Actions - Replace String in Text File

note

This action works only with text-based files such as .ini, .xml, .json, or plain-text files. It does not support binary file editing.

Fields

FieldDescription
PathSpecifies the target file to update.
Find whatSpecifies the text value to search for.
Replace withSpecifies the value that replaces the matched text.
EncodingSpecifies the target file encoding, such as UTF-8 or ANSI.
Regex DisabledTreats Find what as a literal text value instead of a regular expression.
Non case sensitiveMakes the search case-insensitive.
info

Select the correct Encoding. Using the wrong encoding can corrupt the file contents.

Steps

  1. Open the MSI or MST in Master Packager.
  2. In the left pane, select Custom Actions.
  3. Open the Predefined Actions tab.
  4. Click Add New Predefined Action and select Replace String in Text File.
  5. Set Path to the target file.
  6. Enter the search value in Find what.
  7. Enter the replacement value in Replace with.
  8. Select the correct Encoding.
  9. Enable Regex Disabled if you want to search for literal text only.
  10. Enable Non case sensitive if the search should ignore letter case.
tip

Back up important files and confirm the encoding before running the action.