Search code examples
wixwindows-installercustom-actionwix-extension

WiX 3.8 CAQuietExec and command string


I'm trying to do a custom action when unistalling an Application. These should be done in quiet mode. Therefore I've that part of code to make it working:

<?xml version="1.0"
      encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <Property Id="APPFOLDER">
            <RegistrySearch Id="PATH"
                    Key="Software\[Manufacturer]\[ProductName]"
                    Root="HKLM"
                    Type="raw"
                    Name="InstallPath" />
        </Property>
        <CustomAction Id="CleanupAppDirCmd"
                      Property="CleanupAppDir"
                      Value='rmdir /s/q "[APPFOLDER]"'
                      Execute="immediate"/>
        <CustomAction Id="CleanupAppDir"
                      BinaryKey="WixCA"
                      DllEntry="CAQuietExec"
                      Execute="deferred"
                      Return="ignore"
                      Impersonate="no"/>
        <InstallExecuteSequence>
            <Custom Action="CleanupAppDirCmd"
                    After="CostFinalize"/>
            <Custom Action="CleanupAppDir"
                    After="RemoveFiles">
                REMOVE="ALL"
            </Custom>
        </InstallExecuteSequence>
    </Fragment>
</Wix>

But nothing happens. The directory still exists after finishing the uninstall. The uninstall-log tells me following:

MSI (s) (F8:20) [16:57:15:778]: Executing op: ActionStart(Name=CleanupAppDir,,) MSI (s) (F8:20) [16:57:15:779]: Executing op: CustomActionSchedule(Action=CleanupAppDir,ActionType=3137,Source=BinaryData,Target=CAQuietExec,CustomActionData=rmdir /s/q "C:\Program Files (x86)\Company\") MSI (s) (F8:20) [16:57:15:780]: Creating MSIHANDLE (111) of type 790536 for thread 6176 MSI (s) (F8:C0) [16:57:15:780]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI6D67.tmp, Entrypoint: CAQuietExec MSI (s) (F8:5C) [16:57:15:780]: Generating random cookie. MSI (s) (F8:5C) [16:57:15:782]: Created Custom Action Server with PID 6872 (0x1AD8). MSI (s) (F8:78) [16:57:15:809]: Running as a service. MSI (s) (F8:78) [16:57:15:810]: Hello, I'm your 32bit Elevated custom action server. MSI (s) (F8!4C) [16:57:15:819]: Creating MSIHANDLE (112) of type 790531 for thread 2892 MSI (s) (F8!4C) [16:57:15:820]: Closing MSIHANDLE (112) of type 790531 for thread 2892 MSI (s) (F8!4C) [16:57:15:820]: Creating MSIHANDLE (113) of type 790531 for thread 2892 CAQuietExec: Command string must begin with quoted application name. MSI (s) (F8!4C) [16:57:15:820]: Closing MSIHANDLE (113) of type 790531 for thread 2892 MSI (s) (F8!4C) [16:57:15:820]: Creating MSIHANDLE (114) of type 790531 for thread 2892 CAQuietExec: Error 0x80070057: invalid command line property value MSI (s) (F8!4C) [16:57:15:820]: Closing MSIHANDLE (114) of type 790531 for thread 2892 CAQuietExec: Error 0x80070057: failed to get Command Line

I've tried several changes in the value of CleanupAppDirCmd but nothing worked. What I'm doing wrong?


Solution

  • rmdir isn't an EXE that can be executed, it's a shell command internal to cmd.exe.

    I'd suggest looking at RemoveFolderEx Element (Util Extension). It'll be a much better solution including rollback of the delete if the install fails or is cancelled. (Very important)