2014-09-02 66 views
1

我想在執行應用程序時執行自定義操作。這些應該在安靜模式下完成。因此,我有這部分代碼,使其工作:WiX 3.8 CAQuietExec和命令字符串

<?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> 

但沒有任何反應。完成卸載後該目錄仍然存在。卸載日誌告訴我下面的:

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

我試過在CleanupAppDirCmd值幾個變化,但毫無效果。我做錯了什麼?

回答

1

rmdir不是可執行的EXE,它是cmd.exe內部的shell命令。我想建議看看RemoveFolderEx Element (Util Extension)。這將是一個更好的解決方案,包括在安裝失敗或取消時回滾刪除。 (非常重要)

+0

是的,使用類似MSI的shell命令是一種反模式,除非在適當的錯誤和異常處理中正確嵌入編碼自定義動作 - 即使如此,如果有替代方案,我也不會使用它。絕對使用Util擴展。 – 2014-09-02 17:26:55

+0

非常感謝您的回答。 'RemoveFolderEx'元素的位置有點棘手(作爲'component'的子元素),但它完全解決了我的問題。 – frankenpfalzer 2014-09-03 09:14:39