How do I make WIX execute command immediately at uninstall

时间:2017-12-18 08:36:59

标签: windows batch-file wix

I have a java desktop application which is using WIX to install the application. At install WIX is creating a folder located in the {...}/AppData/Local folder. The application is then populating this folder with subfolders and files during execution of the application.

We noticed that at uninstall of the application this folder is not removed (if it is populated, if it is empty it is removed via the RemoveFolder elelemt) which leads to unpleasantries.

Reasearch into the matter shows that the RemoveFolder element can only remove empty folders, ie. without subfolders and files. For solving the issue I came up with the solution of executing a batch file with code for removing the whole folder, including sub folders and files, via a Custom Action. I thought of placing this file in the installation path of the application, which is not the same as where the folder I want to remove is placed.

After turning on logging for installing/uninstalling the application I find that this custom action is not executedc in the correct order, ie. it is executed after the installation folder is removed and thereby the batch file is never run.

Here is my WIX InstallExecuteSequence:

mvn clean install

Here are parts of the install/uninstall log file:

  <InstallExecuteSequence>

     <Custom Action='RemoveAlelionFolder' After="InstallFiles">
         Installed AND NOT UPGRADINGPRODUCTCODE
     </Custom>
      <RemoveExistingProducts After="InstallValidate"/>

  </InstallExecuteSequence>

  <CustomAction Id='RemoveAlelionFolder' ExeCommand='[INSTALLDIR]remove.bat' Directory="INSTALLDIR" Execute="deferred" Return='asyncNoWait' />

Some research effort: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Removing-Folders-td703071.html Removing files when uninstalling WiX How to add a WiX custom action that happens only on uninstall (via MSI)? https://stackoverflow.com/questions/320921/how-to-add-a-wix-custom-action-that-happens-only-on-uninstall-via-msi

1 个答案:

答案 0 :(得分:1)

解决!

我必须运行自定义操作&#39; After =&#39; InstallInitialize&#39;为了使它能够在代码流中的正确位置运行。

[Symfony\Component\Console\Exception\CommandNotFoundException]
  Command "list" is not defined.
  Did you mean this?
      list