As you know, when you ship VCRedist_X86 with the installer and when the user install your software, VCRedist leaves 24 temporary files on C drive and sometimes on D .. Depending where the operating system is installed.
in Inno scripts, this code deletes all those file after the finish of installation:
how to do this using NSIS in a certain Section?
procedure DeleteVCRedistRuntimeTemporaryFiles();
var
i : Integer;
byCounter : Byte;
byDrive : Byte;
strFile1, strFile2, strFile3 : String;
strRootDrivePath : String;
//totally there are 24 files to be deleted
arrFiles : Array [1..24] Of String;
begin
//We will check the following root drives
//C, D, E, F, G, H, I, J, K, L, M
For byCounter := 67 to 77 do
Begin
strRootDrivePath := Chr(byCounter) + ':\';
arrFiles[1] := strRootDrivePath + 'vcredist.bmp';
arrFiles[2] := strRootDrivePath + 'VC_RED.cab';
arrFiles[3] := strRootDrivePath + 'VC_RED.MSI';
//If these 3 files then we have found the right
//drive in which the VC runtime files are extracted
If (FileExists(arrFiles[1]) And
FileExists(arrFiles[2]) And
FileExists(arrFiles[3])) Then
Begin
arrFiles[4] := strRootDrivePath + 'eula.1028.txt';
arrFiles[5] := strRootDrivePath + 'eula.1031.txt';
arrFiles[6] := strRootDrivePath + 'eula.1033.txt';
arrFiles[7] := strRootDrivePath + 'eula.1036.txt';
arrFiles[8] := strRootDrivePath + 'eula.1040.txt';
arrFiles[9] := strRootDrivePath + 'eula.1041.txt';
arrFiles[10] := strRootDrivePath + 'eula.1042.txt';
arrFiles[11] := strRootDrivePath + 'eula.2052.txt';
arrFiles[12] := strRootDrivePath + 'eula.3082.txt';
arrFiles[13] := strRootDrivePath + 'globdata.ini';
arrFiles[14] := strRootDrivePath + 'install.exe';
arrFiles[15] := strRootDrivePath + 'install.ini';
arrFiles[16] := strRootDrivePath + 'install.res.1028.dll';
arrFiles[17] := strRootDrivePath + 'install.res.1031.dll';
arrFiles[18] := strRootDrivePath + 'install.res.1033.dll';
arrFiles[19] := strRootDrivePath + 'install.res.1036.dll';
arrFiles[20] := strRootDrivePath + 'install.res.1040.dll';
arrFiles[21] := strRootDrivePath + 'install.res.1041.dll';
arrFiles[22] := strRootDrivePath + 'install.res.1042.dll';
arrFiles[23] := strRootDrivePath + 'install.res.2052.dll';
arrFiles[24] := strRootDrivePath + 'install.res.3082.dll';
For i := 1 to 24 Do
Begin
DeleteFile(arrFiles[i]);
End;
//Now that we have found and deleted all the files
//we will break
Break;
End;
End;
End;
procedure DeinitializeSetup();
begin
DeleteVCRedistRuntimeTemporaryFiles();
end;