[wix-users] Unable to delete files from install dir using Custom action

Hoover, Jacob Jacob.Hoover at greenheck.com
Thu Nov 11 13:15:50 PST 2021


https://wixtoolset.org/documentation/manual/v3/xsd/wix/removefile.html


From: wix-users <wix-users-bounces at lists.wixtoolset.org> On Behalf Of Shir Borer via wix-users
Sent: Thursday, November 11, 2021 3:12 PM
To: wix-users at lists.wixtoolset.org
Cc: Shir Borer <shir.b at lls-ltd.com>
Subject: [wix-users] Unable to delete files from install dir using Custom action

Hello all! I'm trying to create a custom action which will delete files in the installation folder.
I first tried using a "cmd.exe" action:

<CustomAction Id="InstallService" Return="check" Impersonate="no" Execute="deferred" Directory="INSTALLFOLDER" ExeCommand='cmd.exe /C del /s /q "[INSTALLFOLDER]"'/>
<InstallExecuteSequence>
<Custom Action="InstallService" Before ="InstallFiles">NOT REMOVE</Custom>
</InstallExecuteSequence>

This worked for me but failed on some computers with:
Error 1721. There is a problem with this Windows Installer package. A program required for this install to complete could not be run. Contact your support personnel or package vendor
Trying different impersonate and Execute value did not help.

Then I tried to create a DLL custom action. in which I do:

//string installDir = session["installDir"];
string installDir = session.CustomActionData["installDir"];
session.Log($"install: {installDir}");

System.IO.DirectoryInfo di = new DirectoryInfo(installDir);

foreach (FileInfo file in di.GetFiles())
{ ...

​This also fails, and although the log prints the correct path:
install: C:\Users\Shir\AppData\Local\INSTALL\
I get error:
Could not find a part of the path 'C:\WINDOWS\Installer\MSIF072.tmp-\C:\Users\Shir\AppData\Local\INSTALL\'

Why is this tmp directory prepended to my path?
I would appreciate any help in finding out the proper way to delete files from the installation folder.

Thanks in advance
-Shir.

____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/<http://www.firegiant.com>
NOTE: This email was received from an external source. Please use caution when opening links or attachments in the message.


More information about the wix-users mailing list