Append or prepend text line in file

About

This is a custom created predefined action by the Master Packager team that can add text lines to the beginning or end of a file. It is useful for adding configuration or service entries automatically during installation.
The action runs under SYSTEM privileges, which allows it to modify files located in protected system directories, provided the SYSTEM account has permission to write to those files.

A typical use case is modifying the Windows services file:

C:\Windows\System32\drivers\etc\services

This is often done to add custom ports for specific applications.

Master Packager Advanced Editor - Predefined Custom Actions - Append or prepend text line in file

Configuration Options

Action Name
Describes what the action will do. Useful for identifying multiple actions in the same package.

Path
Specifies the full path to the file where text lines will be added or inserted.

Text lines
Lists the exact lines of text that will be written into the file. You can add multiple lines as needed.

Append or prepend text line in file - Text lines
You can:
enter image description here

Encoding
Defines the encoding format for the target file, for example, UTF-8 or ANSI. Choosing the correct encoding is important to prevent characters from appearing incorrectly in the resulting file.

Append or prepend text line in file - Endcoding

Placement
Controls whether the text lines are added:

  • Append - Adds lines at the end of the file.
  • Prepend - Inserts lines at the very beginning of the file, before any existing content.

Check if line already exists in file
When enabled, prevents duplicate lines from being added if the same line is already present. The check scans the entire file content.

Non-case sensitive
When enabled, line comparisons ignore differences between uppercase and lowercase letters.