是否可以通过自定义操作读取包装代码,就像读取ProductCode和ProductName一样。我想删除在%LOCALAPPDATA%/ Downloaded Installations / GUID中创建的MSI缓存,其中GUID是卸载过程中的软件包代码。
您可能想看看我前一段时间写的这段代码:(整个线程很不错)
<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;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句