EzBatchAddPath

InstallShield 2018 » InstallScript Language Reference

The EzBatchAddPath function modifies the default batch file by adding a path either to the search path in a PATH command or to the value assigned to an environment variable. Unless it is changed by a call to BatchSetFileName, the default batch file is the Autoexec.bat file that was executed by the system during the boot sequence. To determine the fully qualified name of the default batch file, call BatchGetFileName. To change the name of the batch file to be used by EzBatchAddPath, call BatchSetFileName.

Caution • EzBatchAddPath does not make a backup copy of the file it modifies.

EzBatchAddPath can fail if the default batch file is hidden or read-only.

Note • Do not mix Ez batch file functions and advanced batch file functions. After calling BatchFileLoad to load a batch file in memory, you cannot call any of the Ez batch file functions until you call BatchFileSave to save the file.

Syntax

EzBatchAddPath ( szKey, szPath, szRefDir, nPosition );

Parameters

EzBatchAddPath Parameters

Parameter

Description

szKey

Specifies the name of the environment variable to modify. For example, to modify the PATH statement, specify "PATH" here. If the specified environment variable is not found in the default file batch file, a complete SET statement is created for that environment variable and inserted into the file.

Caution • The EzBatchAddPath function does not support long file names. Call LongPathToShortPath to convert the long path to its short path equivalent before passing it to EzBatchAddPath. For an explanation of long file names, see Long File Names.

szPath

Specifies the path to add to the current value of the environment variable. A delimiting semicolon is inserted to separate it from other paths in the search path.

szRefDir

Specifies the reference key (a path) relative to which you are adding the new path specified by szPath. If this is a null string (""), the directory is added to the beginning or end of the search path, depending on the value of nPosition. If the path specified by szRefDir is not found in the search path, the value of szKey is added to the end.

nPosition

Specifies where in the search path to add the new path. Pass one of the following predefined constants in this parameter:

BEFORE—The new path is inserted before the path specified by szRefDir. If szRefDir contains a null string (""), the directory is added to the front of the search path.
AFTER—The new path is inserted after the path specified by szRefDir. If szRefDir contains a null string (""), the directory is added to the end of the search path.

Return Values

EzBatchAddPath Return Values

Return Value

Description

0

EzBatchAddPath successfully added the path to the batch file.

< 0

EzBatchAddPath was unable to add the path to the batch file.

See Also