Skip to main content

Append or Prepend Text Line in File

Use this predefined action to add one or more text lines to the beginning or end of a file during installation.

A common use case is updating C:\Windows\System32\drivers\etc\services to add custom ports for an application.

Master Packager Advanced Editor - Predefined Custom Actions - Append or Prepend Text Line in File

Main Fields

FieldDescription
Action NameIdentifies the predefined action when the project contains multiple custom actions.
PathSpecifies the full path to the file that will be updated.
PlacementChooses Append to add lines at the end of the file or Prepend to insert them at the beginning.
Check if line already exists in filePrevents duplicate lines from being added.
Non-case sensitiveIgnores letter case when checking whether a line already exists.

Text Lines

The Text lines list contains the exact lines that will be written to the file.

Append or Prepend Text Line in File - Text Lines

Manage Text Lines

Use the toolbar to add, edit, or remove lines.

Append or Prepend Text Line in File - Toolbar

Encoding

Choose the correct encoding, such as UTF-8 or ANSI, so the updated file keeps the expected character set.

Append or Prepend Text Line in File - Encoding

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 Append or Prepend Text Line in File.
  5. Enter a value in Action Name.
  6. Set Path to the file that should be updated.
  7. Add the required entries under Text lines.
  8. Choose the appropriate Encoding.
  9. Select Placement.
  10. Optionally enable Check if line already exists in file and Non-case sensitive.