Shop

InstallShield
Advanced Installer
AdminStudio
more / weitere

InstallShield und AdminStudio Schulungen

weitere Infos

InstallShield InstallScript: Components and Files

Note regarding InstallScript versions: The samples on this page have been developed with various versions of InstallShield. Some of them require a minimum InstallShield version or may only work in the one version they have been created for. Often it will be possible to make them compatible with other InstallShield versions.

Backup Modified Files

The following function backs up existing files only if they have been changed from a previous installation. For this purpose it compares date and size information of the file in the target location and the version you are about to install. If they differ, a backup copy of the file is created.

This function is not compatible with IS6.

prototype BackupIfNeeded(STRING, STRING, STRING, STRING);

ZIP BackupIfNeeded.zip   Written by Kristjan Hakonarson
File size: 1.095 bytes   Last update: 03/16/1999

Backup Replaced Files

There is no current IS5 built-in capability for to backup replaced files. Here is a workaround for this defficiency. You must call this function for each filegroup in your setup. A sample rul file is included.

This function is not compatible with IS6.

prototype CompareBackupSharedFiles(STRING, STRING, STRING);

ZIP bkfile.zip (2727 Bytes)   Provided by Jeff McCollum

Clone Time Stamp

This function will clone the timestamp (modified, last accessed and created) of a source file onto a target file. It was tested with IS6.31 but it should work with 5.5 and 7.0 as well.

ZIP CloneTimeStamp.zip   Written by Geoffrey Faivre-Malloy
File size: 729 bytes   Last update: 2003-01-24

Component and List Functions

This is a collection of list related functions to manage components. Among others, there are functions copy and logical combine lists, translate compononents into lists and vice versa, etc.

ZIP lists.zip (2.588 Bytes)   Provided by T.K.Wessing

ComponentSelectItem() for Invisible Components

Invisible components can only be (de)selected by being required components of visible components (the invisible components are then selected/deselected as a cascade from the visible component). The following function gets around this by temporarily making the component visible if it is invisible.

prototype _ComponentSelectItemForce ( STRING, STRING, BOOL );

ZIP componentselectitemforce.zip (1.056 Bytes)   Provided by Carl Bennett based on a function by James Frater

Delete All Instances of a File

This functions works similar to FindAllFiles, but it also deletes the files it found. It returns the fully-qualified path of the file it deleted for logging purposes.

prototype DeleteAllFiles(STRING, STRING, BYREF STRING, NUMBER);

ZIP deleteallfiles.zip (474 Bytes)   Provided by Stefan Krueger

Delete Files Using the Recycle Bin

In contrast to DeleteFile, which wipes the file from the user's hard disk, this function will send a file to the recycle bin.

prototype Recycle(STRING);

ZIP recycle.zip   Written by Mike Mckee
File size: 485 bytes   Last update: 05/16/1999

Directory and File Operations

This script provides users with the functionality to move, copy, delete or rename directories (or files). It uses the exported function SHFileOperation from Shell32.dll.

prototype INT DirOperation( STRING, STRING, STRING );

ZIP DirOperations.zip   Written by Rob Gommans
File size: 1.386 bytes   Last update: 2000-09-04

Display Component Error Messages

This is a replacement for the HandleMoveDataError function in your script. It interprets the error numbers into English, based on the IS help. It also logs it in the Install.log file, and displays the error to the user. Currently it isn't using the string table. The error texts are hard coded in the script.

prototype HandleMoveDataError(NUMBER);

ZIP handlemovedataerror.zip (1.835 Bytes)   Provided by William Randlett

Enhanced Version of FindAllFiles

This file searching function is a little different than FindAllFiles. There is an option for whether or not to search subdirectories. The files are returned in a list with their full path.

prototype GetFileList( STRING, STRING, BOOL, BYREF LIST );

ZIP getfilelist.zip (717 Bytes)  Provided by Ryan Lewandowski

Enumerate Files to be Installed

This script goes through the component tree and adds all the associated files to a string list. You can chose to list only files in selected components, or all files. The function does not take into account operating system or language filters.

This function is not compatible with IS6.

ZIP enumfiles.zip (1.650 Bytes)  Provided by Richard Aquino, InstallShield Software Corporation

Expand System Variables in ComponentGetData

When you call ComponentGetData with COMPONENT_FIELD_DESTINATION, the returned string may include literal names of system variables like "<TARGETDIR>" or script defined folders. This function optionally expands those meta directory names to their actual values.

prototype _ComponentGetData ( STRING, LONG, BYREF LONG, BYREF STRING, STRING );

ZIP componentgetdata.zip (6.162 Bytes)   Provided by James Frater

Finding a File in the PATH

This function allows you to search the environment variable PATH for the occurance of a specified file.

prototype FindFileInPath(STRING, BYREF STRING);

ZIP findfileinpath.zip (1.720 Bytes)    Provided by Stefan Paetow

Get File Dates

This function gets the date and time of a file, either on disk or in a component, in a format suitable for before/after comparisons.

prototype GetFileDate (STRING, BYREF STRING);

ZIP filedate.zip   Written by Alan Frank
File size: 1.038 bytes   Last update: 03/16/1999

Get Size of All Files in a Directory

This function scans through a directory (and optionally its subdirectories) and adds up the size of all files that match the specified wild card. Note that this will be the sum of the bytes making up these files. The disk space actually occupied by these files can be significantly larger, depending on the cluster size of the file system.

prototype GetDirFileSize ( STRING , STRING , BYREF NUMBER , NUMBER );

Updated version: Now calls FindAllFiles with CANCEL to free file handles.

ZIP GetDirFileSize.zip   From the InstallShield newsgroups
File size: 655 bytes   Last update: 2000-02-01

Insert a File into a File

This function inserts a text file into another text file at a specified line number. It was written for ISPro 6.

ZIP InsertFileIntoFile.zip   Written by Michael Steurich
File size: 1.059 bytes   Last update: 2003-06-30

Looking for a Self-Registered File

This script will see if a self-registered file is on the system and, if so, where it's located.

prototype _GetPathToSelfRegisteredFile( STRING, BYREF STRING );

ZIP SRCheck.zip (1.220 Bytes)   Provided by Leslie Easter

Read Product Properties from File

This function can read verious data from the version info resource in a file, not just the file version. It is based on Microsoft's knowledge base article Q160042. Compatability: Windows 2000 and later. This works on 16-, 32-, and 64-bit file images. Tested with installshield 11 premier edition but should also be compatible to older InstallShield versions

ZIP VerGetFileProperty.zip   Written by Dror Bar-Gil
File size: 32.358 bytes   Last update: 2005-12-12

Read ProductVersion from File

InstallShield's VerGetFileVersion function can be used to read the file version, but not the product version stored in the version information block of a file. Here is a script that calls  WinAPIs to get the numerical ProductVersion stored in the VS_FIXEDFILEINFO structure. Note that files typically also include file and product versions as strings, that cannot be extracted with these functions. Windows Explorer only displays these version strings, not the numerical version info. (Execption: Windows 2000 Explorer displays the numerical file version. All other information - including product version - is still taken from the string file info.)

prototype VerGetProductVersion(STRING, BYREF STRING);

ZIP ProductVersion.zip   Written by Mickey Ferguson and Rich Brady
File size: 2.574 bytes   Last update: 2003-06-30

Read Value of Script Defined Folder from Log File in Maintenance Mode

In IS6 script defined folders (like "<szVar>") are implemented using a service called TextSubstitution that is available in the script through the COM object named TextSub. When you do

ComponentSetTarget("", "<szVar>", "C:\\MyDir");

it finally ends up calling

TextSub.Value("szVar") = "C:\\MyDir";

The values of the TextSub object are automatically saved after the file transfer, and you can use TextDub to retrieve them. For example, if you want to display the last saved value of "szVar" in your OnBegin event handler you would do:

function OnBegin()
begin
    if( MAINTENANCE ) then
        MessageBox(TextSub.Value("szVar"), INFORMATION);
    endif;
end;

From newsgroup installshield.is6.general
Last update: 11/26/1999

Replacement for FileInsertLine()

The built in function FileInsertLine() sometimes failes without any obvious reason. This function works around that problem using a stringlist.

prototype MyFileInsertLine(STRING, STRING, NUMBER, NUMBER);

ZIP myfileinsertline.zip (439 Bytes)   Provided by Stephan Hagedorn

Search and Replace a String in a File

This functions loads a file into memory, searches it for a given string and replaces all occurrences.

prototype FileStrReplace ( STRING, STRING, STRING );

ZIP filestrreplace.zip   Written by Mark Kendzior
File size: 1.138 bytes   Last update: 08/07/1999

Updating Locked Files with Long Names

Files that are locking during the setup will be updated on the next reboot. On Windows 9x/Me this is done using wininit.ini and the rename operation takes place on DOS level, without support for long file names. So if a file with long name is locked, it will end up with a name like longfi~1.dll. Windows NT/2000 and later are not affected by this problem.

If you can't avoid to use long file names for potentially locked files, you can use the following script to work around this problem. It works by checking for long filenames in Wininit.ini in the OnEnd event handler. If it finds any, it alters the rename entries to delete the in-use files by their short names on next reboot and also copies the original rename entry into LongInit.ini. The OnRebooted event handler then completes the rename operation by processing the entries in LongInit.ini.

It's only potential drawback is if any locked files are used between the time Windows deletes them and the time the setup re-starts.

This script will not work with IS5.

ZIP LockedLongNames.zip   Written by John Biddle
File size: 1.061 bytes   Last update: 2002-02-02

 

 

 

English News Discussions Windows Installer Related Tools More Help InstallScript About InstallSite Shop Site Search
deutsch Neuigkeiten Diskussionsgruppen Windows Installer MSI FAQ Artikel     Shop Suche

Copyright © by InstallSite Stefan Krueger. All rights reserved. Legal information.
Impressum/Imprint Datenschutzerklärung/Privacy Policy
By using this site you agree to the license agreement. Webmaster contact