cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sreelakshmi
Level 3

DELETE FILE

I am not able to delete the file using custom action .Is  there something wrong with the script.

can someone provide the script to delete the file

Labels (1)
0 Kudos
(1) Reply
varul
Revenera Moderator Revenera Moderator
Revenera Moderator

Hi @sreelakshmi ,

  First we should make sure the path to file is correct,  and at the time of customaction execution the file should be available in the path, 

 

Please refer our installscript sample code for deleting a file, 

https://docs.revenera.com/installshield22helplib/Subsystems/installshield22langref/helplibrary/LangrefDeleteFile_Example.htm#langref_appendixa_619625892_1028131

Sample code to delete file from installdir:, You this code and create a installscript CA and sequence it proper order, If the file is installed by your installer then i suggest you to sequence it to,  After installfinalize

function ExFn_DeleteFile(hMSI)

STRING szMsg;
STRING szInstallDir;
INT nvSize;

begin
nvSize= MAX_PATH;
if MsiGetProperty(hMSI, "INSTALLDIR", szInstallDir, nvSize) = ERROR_SUCCESS then
MessageBox( "[INSTALLDIR] = '" + szInstallDir + "'", INFORMATION);
else
MessageBox( "Could not retrieve value of [INSTALLDIR] !!", WARNING);
endif;

MessageBox("szInstallDir is= " + szInstallDir, INFORMATION);

DeleteFile(szInstallDir+"\\Test.config");
end;

0 Kudos