This page explains how you can change CONFIG.SYS with the CONFIGSYS attribute of the opening PCK tag.

However, note that we do not recommend changing CONFIG.SYS in the first place. With many applications, CONFIG.SYS changes are the result of a lack of conceptual design on the programmer's part. Especially if you think of changing the system paths to point to your installation directory, think again. This forces the user to reboot, slows down the system, makes de-installation more difficult, and moving application directories on the hard disk becomes a real hassle. 99% of all applications do NOT need to have system paths changed if you simply use the OS/2 APIs to query information about your executable.

Basically, I can only think of four situations where changing CONFIG.SYS would actually be necessary:

  1. Device drivers, of course.

  2. Applications which replace parts of the system (such as command shells, system DLL replacements, and such). For registering WPS classes however, changing CONFIG.SYS is almost never necessary, since the WPS class list supports specifying full paths. To prove this thesis: XWorkplace is one of the most complex WPS class replacements available and it does not need CONFIG.SYS to be changed.

  3. Registering global system DLLs with the SYS_DLLS keyword in OS2.INI to modify the behavior of Presentation manager. Those DLLs have to be on the LIBPATH.

  4. Large system extensions which add lots of new functionality and are a base for other programs, such as EMX or XFree/2. These create a complete directory tree, including BIN and DLL directories, into which other software will insert their stuff as well. But then again, much of the environment which these packages need can be created using CMD scripts, which saves the user from rebooting every time the environment changes.
OK, enough preaching. The CONFIGSYS="statement[|modifiers...]" attribute to the opening PCK tag is a bit complex, but very flexible.

Per default (that is, if no modifiers are specified), the CONFIGSYS attribute will simply add statement in a new line to the end of the user's CONFIG.SYS file without any further checking.

Example: CONFIGSYS="SET RESTARTOBJECTS=NO" would add that line to the bottom of CONFIG.SYS (even if another SET RESTARTOBJECTS statement already existed).

However, there are many modifiers available which allow for a more flexible CONFIG.SYS manipulation, which is necessary in many cases. These modifiers must appear after a "|" character.

UNIQUE[(statement2)]
This makes sure that the statement part of the CONFIGSYS attribute occurs only once, i.e. will be unique in CONFIG.SYS, by searching for a similar line and replacing that line with the new line. If no such similar line is found, the new line is appended to the bottom of CONFIG.SYS (that position can be changed with ADDTOP, ADDBEFORE, ADDAFTER).

All searching is case-insensitive.

This assumes that statement contains a "=" character, as all CONFIG.SYS statements do. The exact behavior of UNIQUE depends on the syntax:


ADDRIGHT
This assumes that statement contains a "=" character and searches CONFIG.SYS for that first part. This is useful for path statements (SET PATH and the like).

If the first part of statement is found, the part after the "=" character is appended to that line in CONFIG.SYS. If no corresponding line is found, a new line is added to the bottom of CONFIG.SYS (that position can be changed with ADDTOP, ADDBEFORE, ADDAFTER).

This cannot be used with UNIQUE or ADDLEFT.

Example:

CONFIGSYS="SET PATH=$(1)\BIN | ADDRIGHT"
appends the BIN subdirectory of the target path of package 1 to the system path, using macro resolution.
ADDLEFT
Same as ADDRIGHT, but the part after the "=" character is inserted at the beginning of the list. This is only recommended if your data needs to appear first in the list (e.g. for replacing system DLLs). Be very careful with this one, this can lead to real problems.

This cannot be used with UNIQUE or ADDRIGHT.

ADDTOP or ADDAFTER(xxx) or ADDBEFORE(xxx)
Per default, lines are added to the bottom of CONFIG.SYS. These keywords modify this behavior so that lines are inserted at the very top, before, or after a line containing the specified search string "xxx".

Examples:

CONFIGSYS="BASEDEV=CRASHSYS.ADD /DOCRASH | UNIQUE(CRASHSYS.ADD) ADDBEFORE(IBM1S506.ADD)"
searches CONFIG.SYS for the line containing IBM1S506.ADD (the IBM IDE driver) and inserts BASEDEV=CRASHSYS.ADD / DOCRASH right before that line.
CONFIGSYS="SET INCLUDE=$(1)\INCLUDE | ADDRIGHT ADDAFTER(SET BOOKSHELF)"
searches CONFIG.SYS for a line starting with SET INCLUDE=. If such a line is found, assuming that the target path of package 1 is "F:\WHATEVER", "F:\WHATEVER\INCLUDE" is appended to that line. If that line is not found, a new line containing SET INCLUDE=F:\WHATEVER\INCLUDE is added before the line which contains SET BOOKSHELF=. Whoa.
REMOVELINE
This removes a whole line from CONFIG.SYS. In this case, statement is taken as a search string. If that string is found, the whole line which contains it is removed.

Example:

CONFIGSYS="BASEDEV=CRASHSYS.ADD | UNIQUE(CRASHSYS.ADD) ADDBEFORE(IBM1S506.ADD)"
CONFIGSYS="BASEDEV=IBM1S506.ADD | REMOVELINE"
replaces IBM1S506.ADD with CRASHSYS.ADD.
REMOVEPART
This removes some data from a line in CONFIG.SYS.

If a "=" character is found in statement, the CONFIG.SYS line starting with the first part of statement is searched, and the second part of statement is removed. (Useful for SET PATH=WHATEVER and the like.)