Is it possible to read package code through custom action as reading ProductCode and ProductName. I want to remove the MSI cache being created in %LOCALAPPDATA%/Downloaded Installations/GUID, where GUID is the package code during uninstallation.
You might want to take a look at this code I wrote awhile back: (the entire thread is a good read)
Local cached MSI does not get deleted when uninstalling
<CustomAction Id="PurgeCache_CAD_Install" Execute="immediate" Property="PurgeCache" Value="/CacheRoot=[CommonAppDataFolder]Downloaded Installations\MyCompany\MyProduct /PackageCode=[PackageCode] /InstallMode=Install"/>
<CustomAction Id="PurgeCache_CAD_Uninstall" Execute="immediate" Property="PurgeCache" Value="/CacheRoot=[CommonAppDataFolder]Downloaded Installations\MyCompany\MyProduct /PackageCode=[PackageCode] /InstallMode=UnInstall"/>
<InstallExecuteSequence>
<Custom Action="PurgeCache_CAD_Install" After="ScheduleReboot">Not REMOVE="ALL"/>
<Custom Action="PurgeCache_CAD_Uninstall" After="ScheduleReboot">REMOVE="ALL"/>
</InstallExecuteSequence>
export prototype PurgeCache(HWND);
function PurgeCache(hMSI)
number nResult;
string szInstallMode;
string szCacheRoot;
string szDir;
string szPackageCode;
LIST listDirs;
begin
szInstallMode = MsiGetCustomActionDataAttribute( hMSI, "/InstallMode=" );
szCacheRoot = MsiGetCustomActionDataAttribute( hMSI, "/CacheRoot=" );
szPackageCode = MsiGetCustomActionDataAttribute( hMSI, "/PackageCode=" );
listDirs = ListCreate (STRINGLIST);
FindAllDirs( szCacheRoot, EXCLUDE_SUBDIR, listDirs );
nResult = ListGetFirstString (listDirs, szDir);
while (nResult != END_OF_LIST);
if ( szInstallMode = "Uninstall" || !( szDir % szPackageCode )) then
DeleteDir( szDir, ALLCONTENTS );
endif;
nResult = ListGetNextString (listDirs, szDir);
endwhile;
return ERROR_SUCCESS;
end;