How can I obtain filename of own MSI/EXE installer file?

81 Views Asked by At

I need to get a filename of the own installation package within an InstallScript function. How can I do that?

2

There are 2 best solutions below

1
renewinkel On BEST ANSWER

SETUPEXEDIR and SETUPEXENAME are MSI properties. You can obtain their values through the MsiGetProperty function. If you are not using an MSI then you can use the PACKAGE_LOCATION system variable, as in

ParsePath(svSetupExeFileName, PACKAGE_LOCATION, FILENAME);
1
ababo On

I have found a way to get the filename:

function ShowInstallerFilename(hMSI)
    NUMBER maxPath;
    STRING originalDatabase;
begin
    maxPath = MAX_PATH;
    if(MsiGetProperty(hMSI, "OriginalDatabase", originalDatabase, maxPath) == ERROR_SUCCESS) then
        SprintfBox(INFORMATION, "Deferred Execution", "Original database is %s", originalDatabase);
    endif;

    MessageBox("Done", INFORMATION);
end;