DeleteFile

InstallShield 2013 » InstallScript Language Reference

The DeleteFile function deletes one or more files.

Project: In a Basic MSI or InstallScript MSI project, this functionality might be better achieved by using the native Windows Installer RemoveFiles action. For more information, see the Windows Installer Help.

Note: Note the following:

You cannot use DeleteFile to delete files on a network system where you lack the appropriate rights.
DeleteFile cannot delete read-only, hidden, or system files.
You can use wild-card characters with FindFile to locate files and then delete them with DeleteFile.

Syntax

DeleteFile ( szFile );

Parameters

DeleteFile Parameters

Parameter

Description

szFile

Specifies the names of the files to delete. If szFile specifies a fully qualified file name, that is, if it includes a path, DeleteFile will delete the file from specified directory. If szFile contains an unqualified file name, that is, without path information, DeleteFile deletes the file from the directory that is specified by the system variable TARGETDIR (in InstallScript installations) or INSTALLDIR (in Basic MSI and InstallScript MSI installations). You can include wildcard characters in szFile to delete more than one file.

Return Values

DeleteFile Return Values

Return Value

Description

0

Indicates that the function successfully deleted the specified file or files.

ISERR_PATH_NOT_FOUND (0x80070003)

The specified path was not found.

ISERR_FILE_NOT_FOUND (0x80070004)

The specified file was not found or no files matched the specified wildcard.

All other negative values

Indicates that the function was unable to delete one or more of the specified files. In the case of multiple files, only the error for the last file that could not be deleted is returned. The system variable ERRORFILENAME contains a semicolon delimited list of the files that could not be deleted.

You can obtain the error message text associated with a large negative return value—for example, -2147024891 (0x80070005)—by calling FormatMessage.

See Also