19 battallers in the INSTALLSHIELD internal library function
19.1 Advanced Batch File Function
Advanced batch file functions and EZ batch file functions are different, providing greater flexibility and more control over batch files. These functions are used when making more expansion and more complex modifications to a batch file.
To edit a batch file with these advanced functions, you must first load the file into memory by calling BatchFileLoad. When you have completed the changes to the batch file, you must call BatchFileSave to save the file.
When installing initialization, it selects the startup batch file of the target system (autoexec.bat) as the default batch file (unless you modify by calling BatchSetFileName), if you do not specify other file names, the file is filed by BatchFileLoad to memory. . To determine the full-qualified name of the default batch file, call BatchGetFileName.
Do not mix the EZ configuration file function and the advanced profile function. After calling BatchFileLoad until you call BatchFileSave to save your changes, you can use the EZ configuration file function.
Batchadd
Add an environment variable to a batch file.
Batchdeleteex
Delete a line in the batch file.
BatchfileLoad
Put a batch file into the memory to edit it with a high-level batch function.
Batchfilesave
Save a batch file that is loaded by BatchFileLoad.
Batchfind
Find items in a batch file.
BatchGetFileName
Search for the list of fully qualified files.
BatchMoveex
Move a project in a batch file.
BatchSetFileName
Specifies a batch file as the default batch file.
related functions:
SDShowFileMods
19.1.1 Batchadd
Syntax: BATCHADD (Szkey, SzValue, Szrefkey, NOPTIONS);
Note: The BATCHADD function is inserted into a set command or other DOS command to a batch file that has been loaded by BatchFileLoad into the memory. Parameters NOPTIONS allows you to add a new command to the first or last statement of the file, replacing an existing statement with a new command, or specify the new command to add a new command to the front or back of the existing statement.
Unless you use the constant command to use or operate to the NOPTIONS or operator connection, BATCHADD automatically adds the DOS Keyword SET to the beginning of the statement you want to insert. If you don't have a NOPTIONS explicitly specify Replace, the specified statement will be added even if there is a duplicate row in the batch file.
Before calling BATCHADD, you must call BatchFileLoad to load the file you want to modify into memory. After you modify the file, call BatchFileSave to save it to disk.
parameter:
SZKey
Specifies the keyword to be added to the batch file. PATH, TEMP and MYENV are examples of the valid value of this parameter.
SzValue
Specifies the value of the keyword to be added to the batch file. This string must not be longer than 512 bytes; the string that is transmitted longer than 512 bytes will cause an installation error. To add a longer string, use the fileGrep and fileinsetline functions.
The batch file does not support long path names. If you use this function to add a line that contains a long path name, you must first call longpathtoshortpath to convert the long path name into its equivalent short path, and then insert it into the string to add to the batch file.
Szrefkey
Specifies the reference items related to the SZKEY you add in the batch file.
NOPTIONS
Specifies where the row is inserted into the file. One of the following predefined constants in this parameter location:
Before: This statement is added to the front of the first row containing SzrefKey. If szrefkey is an empty string (""), the statement is added to the file first line. After: This statement is added to the back of the last row containing SzrefKey. If Szrefkey is an empty string (""), the statement is added to the file last line.
REPLACE: This statement will exist in the replacement file. If there is a multi-line, only the last line is replaced. If SZKEY is not stored in a file, the new row is added to SzrefKey. If Szrefkey is an empty string (""), the statement is added to the file last line.
When the added statement is not a set command, pass an empty string for Szkey, pass the full command to SzValue, and connect the constant command and other options, as shown below:
Batchadd ("", "Pause", ",", ",", ",
return value:
0: BATCHADD successfully added a set statement or other command to the batch file.
<0: BATCHADD fails to add a set statement or other commands to the batch file.
annotation:
· An InstallShield reference may be an environment variable, a dos command, or a program file name. Environment variables are keywords such as PATH, COMSPEC, LIB, or other predefined or user-defined identifiers. The value of an environment variable uses the dos set command. The statement displayed in a batch file must be a DOS command, the program name (or no command line parameters) or annotations. For detailed definitions of commands and environment variables, see the operating system manual.
19.1.2 BatchDeleteex
Syntax: BatchDeleteex (Szkey, NOPTIONS);
Description: The BatchDeleteex function deletes a row that contains the value specified by SZKey in a batch file. Before calling BatchDeleteEx, you must call BatchFileLoad to load the file you want to modify into memory. After you modify the file, call BatchFileSave to save it to disk.
parameter:
SZKey
Specifies the reference keyword that identifies the row to be deleted.
NOPTIONS
Indicates that Szkey is a command that specifies an environment variable in a set statement or a command. One of the following predefined constants in this parameter location:
0: Specify Szkey is an environment variable in a set statement. An environment variable is a predefined identifier (such as Path, COMSPEC, and LIB), or a user-defined identifier. For example, if the value of SZKEY is "libpath" and the NOPTIONS is set to 0, the following statement will be deleted:
Set libpath = c: / lang / lib
Command: Specify Szkey is a DOS command or a program file name.
return value:
0: BatchDeleteex successfully deletes rows that contain the specified value.
<0: Batchdeleteex failed to delete a row containing the specified value.
19.1.3 BatchFileLoad
Syntax: BatchFileLoad (szbatchfile);
Note: The BatchFileLoad function loads a copy of the specified batch file into the memory so that other advanced batch file functions can be called to operate the file. Specify the batch file name you want to edit or pass an empty string to SZBatchFile to edit the default batch file, which is set by InstallShield initialization to AutoeExec.Bat used by the system.
Note You can call BatchFileLoad to create a new batch file. To do this, you can deliver a file name that does not exist for szbatchfile. Then call other batch functions to edit new files. Finally, call BatchFileSave to save the new file to disk. Before using any advanced batch file function, you must first call BatchFileLoad to load files to be modified into memory. After you modify the file, call BatchFileSave to save it to disk. To get the full qualification of the default batch file used in the installation script, call BatchGetFileName. To specify another default batch file used in the installation script, call BatchSetFileName.
parameter:
SZBATCHFILE
Specifies the full qualification of the batch file to be loaded. In order to load the default batch file, pass an empty string ("") to this parameter. If you specify a file in this parameter, the file is the default batch file. When you call this function, you can use all advanced batch file functions to operate the file.
return value:
0: BATCHFileLoad successfully loads the specified batch file into memory.
<0: BATCHFileLoad failed to load the specified batch file into memory.
19.1.4 Batchfilesave
Syntax: Batchfilesave (Szbackupfile);
Note: The BatchFilesave function saves the batch file that is loaded by the BatchFileLoad function to the disk. The file is saved for its original name. If a file name is specified at Szbackupfile, the original file is written by the original file before the file is written to the file name. If the szbackupfile contains an empty string (""), the original file is replaced by this modified file. If you end with the Advanced Batch File function to modify a batch file, it is not called BatchFileSave, and all modifications will be lost.
parameter:
Szbackupfile
Specifies whether there is a backup of an original file copy before editing is saved.
If you do not need to create a backup file, specify an empty string for this parameter.
If the original file must be backed up with a specific name, pass the file name to this parameter. The file name must be unlimited (i.e., no one drive and / or path). Note If the file with the specified name already exists, BatchFileSave will generate a unique file extension, such as described in the board.
If the original file is backed up, you must have an extension of the installation generated file, specify a wildcard "" as a file extension (for example, "BATCH."). Then the installation will assign a numeric value, starting from 001, as an extension. If a file with this extension already exists, the extension value will increase by 1 until a unique file name.
Once a backup is created, InstallShield saves the backup file name to the system variable infofilename.
Note the following important facts: 1) If the last time the batch file specified for the call for BatchFileLoad does not exist, the backup file will be the same as the batch file created by calling BatchFileSave. 2) If SZBAKUPFILE specifies the original batch file name, a backup file will not be created.
return value:
0: Batchfilesave successfully saves batch files in memory to disk.
<0: BatchFileSave failed to save batch files in memory to disk.
19.1.5 Batchfind
Grammar: Batchfind (Szrefkey, SvResult, NOPTIONS);
Description: The BatchFind function looks for one or more of the reference keyword specified by SzrefKey in a batch file. If you specify a constant restart in NOPTIONS, return to the reference keyword for the first time. To find the next place in Szrefkey, set the parameter nOptions to Continue Repeat the function. Before calling BatchFind, you must call BatchFileLoad to load the file you want to modify into memory. After you modify the file, call BatchFileSave to save it to disk.
parameter:
Szrefkey
Specify the reference keyword to look up. Reference Keywords can be an environment variable, a DOS command or a program name. If the reference keyword is a file name and you do not specify a file extension, the function will return all keywords with the base name. For example, if you specify Win.com, look up only for this reference keyword. If you specify WIN, WIN.EXE files, win.dll files, win.sys files, etc., will be returned if you exist in batch files.
SvResult
Specifies the value of the keyword found in the batch file.
NOPTIONS
Specifies where to start searching; one of the following predefined constants in this parameter location:
CONTINUE: Start searching from the current location of the batch file.
RESTART: Start looking up from the batch file.
When you look for a reference keyword is a DOS command or program name (instead of an environment variable), connect constants Command and Continue or RESTART, as shown below:
Batchfind ("Scan.exe", SvResult, Command | Restart;
return value:
0: BATCHFIND successfully found the value of szrefkey and returned it in SzResult.
<0: BATCHFIND Failed to find the value of szrefkey and returned it in SzResult.
19.1.6 BatchGetFileName
Syntax: BatchGetFileName (SVFileName);
Description: The BatchGetFileName function retrieves the list of the list of default batch files (initially set by InstallShield as the system starts). To specify a different batch file to use the default batch file used in the installation script, call BatchSetFileName.
parameter:
svfilename
Returns the list of default batch files in SZFileName.
return value:
0: BatchgetFileName Successfully retrieves the list of lists of default batch files.
<0: BatchGetFileName failed to retrieve fully qualified names of the default batch file.
19.1.7 BatchMoveex
Syntax: BatchMoveex (Szmove, Szrefkey, NOPTIONS, NMOVEOPTION);
Note: The BatchMoveex function moves a batch file from one line from one position from one position to another. Parameter NOPTIONS specifies that the row is placed in the start or end of the batch file, or in front or behind the row specified by szrefkey. Before calling BatchMoveEx, you must call BatchFileLoad to load the file you want to modify into memory. After you modify the file, call BatchFileSave to save it to disk.
parameter:
Szmove
Specifies the reference keyword that identifies to be moved.
Szrefkey
Specify the keyword, which identifies the reference line used to locate the mobile line. If Szrefkey is an empty string, the row specified by szmove moves to the beginning or end of the file, depending on the value of NOPTIONS.
NOPTIONS
Specifies where to move the row; one of the following predefined constants is passed: Before: The row specified by Szmove is moved to the front of the row containing the Szrefkey reference key. If Szrefkey is an empty string, the row specified by Szmove is moved to the beginning of the file.
After: The row specified by Szmove is moved to the back of the row that contains the Szrefkey reference key. If Szrefkey is an empty string, the row specified by Szmove is moved to the end of the file.
When you look for the reference keyword is a DOS command or program name (instead of an environment variable), connect constants Command and Before or AFORE or operator (|) as follows:
BatchMoveex ("Path", "Scan.exe", Before | Command, 0);
NMOVEOPTION
Specify SZMOVE is a command or an environment variable. Pass one of the following predefined constants to this parameter:
0: Specify SZMOVE is an environment variable.
Command: Specify Szmove is a command.
return value:
0: BatchMoveEx successfully moves the specified line in the batch file.
<0: BatchMoveex failed to move the specified line in the batch file.
19.1.8 BatchSetFileName
Syntax: BatchSetFileName (szbatchfile);
Description: The BatchSetFileName function specifies the batch file name used by the EZ batch file function and call BatchFileLoad when calling BatchFileLoad with an empty string for its parameters. In the installation script, the file is used as the default batch file. During the installation initialization, the default batch file is set as the autoexec.bat file used by the system.
It should pay attention to the facts about BATCHSETFILENAME:
It does not know the existence of the specified file.
It does not load files into memory.
parameter:
SZBATCHFILE
Specifies the full qualification of the file used by the default batch file in the installation script.
return value:
0: BATCHSETFILENAME Successfully Set the specified file to the default batch file.
<0: BatchSetFileName Unable to set the specified file to default batch file.
annotation:
BatchSetFileName simply specifies the name of the default batch file. This function will succeed even if the file name is invalid or the specified file does not exist. An invalid file name will lead to subsequent EZ batch files and advanced batch file functions fail.
19.2 EZ batch file function
The EZ batch file function modifies the default batch file. The default batch file is AutoExec.bat unless you modify by calling BatchSetFileName. It should be noted that each EZ batch file function opens the default batch file and then automatically saves it after modification. You don't have to call your function to open and save when you use the EZ batch file function.
Do not mix the EZ batch file function and the advanced batch file function. After calling BatchFileLoad, you can use the EZ batch file function after you call the BatchFilesave saved file.
Ezbatchaddpath
Modify the default batch file, by adding a path name to a Path command or to a value assigned to the environment variable.
Ezbatchaddstring
Add a line of text to the default batch file.
EzbatchReplace
Replace a statement in the provincial batch file.
19.2.1 ezbatchaddpath
Syntax: Ezbatchaddpath (Szkey, Szpath, Szrefdir, NPosition);
Note: The ezbatchaddpath function modifies the default batch file, by adding a path name to a favorite path of a PATH command or to a value assigned to the environment variable. The default batch file is AutoExec.bat unless you modify by calling BatchSetFileName. Call BatchGetFileName to determine the list of default batch files. To change the file name of the batch file used by EZBATCHADDPATH, call BatchSetFileName. This function does not support long file names. Call the longpathtoshortpath before transferring it to the ezbatchaddpath to convert the long path to its equivalent short path.
parameter:
SZKey
Specifies the environment variable name to modify. For example, to modify the PATH statement, specify "path" here. If the specified environment variable is not found in the default batch file, create a full SET statement for the environment variable and insert it into the file.
Szpath
Specifies the path name to add to the current value of the environment variable. Insert a split semicolon in the lookup path to separate it and other pathnames.
Szrefdir
Specifies the reference keyword (a path name) related to the SZPath new path name you added. If this is an empty string, the pathname is added to the start or end of the lookup path, depending on the NPosition value. If the path name specified by SzregKey is not found in the lookup path, the value of Szkey is added to the end.
NPosition
Specifies where to add a new path name in the lookup path, including the following options:
Before: The new path name is inserted in front of the path name specified by Szrefdir. If szrefdir contains an empty string, the path name is added to the front of the lookup path.
After: The new path name is inserted into the path name specified by SzrefKey. If szrefdir contains an empty string, the path name is added to the end of the lookup path.
return value:
0: EZBATCHADDPATH Successfully adds the path name to the batch file.
<0: EZBATCHADDPATH Fails to add a path name to a batch file.
annotation:
· The default batch file is hidden or read-only when ezbatchaddpath may fail.
· EZBATCHADDPATH does not make a copy of the files it modified.
19.2.2 ezbatchaddstring
Syntax: Ezbatchaddstring (Szline, Szrefkey, NOPTION);
Description: The ezbatchaddstring function adds a text line to the default batch file; unless you modify by calling BatchSetFileName, the default batch file is AutoExec.bat. To determine the full-qualified name of the default batch file, call BatchGetFileName. To modify the name of the batch file used by EZBATCHADDPATH, call BatchSetFileName.
parameter:
Szline
Specifies the text line added to the file. Unless you specify NOSet in NOPTIONS, this function assumes Szline to be an environment variable; in SZLINE is written to the default batch file, the pre-text "SET" is inserted in front of the string.
The batch file does not support long path names. If you use this function to add a line that contains a long path name, you must first call longpathtoshortpath to convert the long path name into its equivalent short path, and then insert it into the string to add to the batch file.
Szrefkey
Specify the reference keyword related to the SZLine you want to add in the default batch file. EZBATCHADDSTRING looks for reference keywords in the default batch file and places the contents of Szline in front or back in the row, according to the value of NOPTIONS.
NOPTIONS
Specify the option used; one of the following predefined constants in this parameter: Before: Szline is added before the row containing the szrefkey. If Szrefkey is an empty string, Szline is added to the first line of the file.
After: Szline is added to the row containing szrefkey. If Szrefkey is an empty string, Szline is added to the last line of the file.
Replace: An existing row in the SZLINE replacement file. If there is a multi-line, ezbatchaddstring only replaces the last line that contains the keyword.
NOSET: Specify text "set" is not inserted in front of the string in SZLINE. This constant can be combined with Before, After, and Replace or operator (|).
When you look for a reference keyword is a DOS command or program name (instead of an environment variable), use or combine constants for Command and other option constants, as shown below:
Ezbatchaddstring (Szline, Szrefkey, After | Command);
return value:
0: EZBATCHADDSTRING Successfully Add a text string to a specified batch file.
<0: ezbatchaddstring Fails to add a text string.
annotation:
· EZBATCHADDSTRING Find the appropriate reference keyword in the parameter szrefkey. For example, a keyword for an environment variable is the name of the environment variable itself.
· If the default batch file is hidden or read-only, EzBATCHADDSTRING may fail.
· EZBATCHADDSTRING does not make a copy of the files it modified.
19.2.3 EzbatchReplace
Syntax: ezbatchReplace (Sznewstring);
Note: EZBatchReplace function Replaces an existing row in the provincial batch file; unless you modify by calling BatchSetFileName, the default batch file is AutoExec.bat. To determine the full-qualified name of the default batch file, call BatchGetFileName. To modify the name of the batch file used by EZBATCHADDPATH, call BatchSetFileName.
parameter:
Sznewstring
Specifies a new string of an existing row in the replacement file.
The batch file does not support long path names. If you use this function to add a line that contains a long path name, you must first call longpathtoshortpath to convert the long path name into its equivalent short path, and then insert it into the string to add to the batch file.
return value:
0: EZBATCHREPLACE Successfully replaced the text line.
<0: ezbatchReplace failed to replace the text.
annotation:
· EZBATCHREPLACE Analysis SzneWString and determines the keyword of the string. It then looks for a line that contains the same keyword in the default batch file. This function is replaced with the last line with the same keyword.
· Some common keywords in a batch file are PATH, COMSPEC, TEMP, SmartDrv.exe, Win.com, and Share.exe.
· If the default batch file is hidden or read-only, the EzbatchReplace function may fail.
· EZBATCHREPLACE does not copy the files it modified.