WixSilentExec不起作用

时间:2017-03-17 15:31:20

标签: wix custom-action

我必须在卸载时默默运行一些cmd行。我试图使用WixSilentExec但它不起作用。有什么问题?

    <Property Id="WixSilentExecCmdLine" Value='cmd /C "rmdir /s/q [DataBaseDir]"' Hidden="yes"/>
    <CustomAction Id="RemoveDataDir" BinaryKey="WixCA" DllEntry="WixSilentExec" Execute="immediate" Return="ignore"/>

    <InstallExecuteSequence>
        <Custom Action="RemoveDataDir" Before="RemoveFiles">DELETEDATADIR="1" OR FORCEDELETE="1") AND (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
    </InstallExecuteSequence>

    <Directory Id="DataBaseDir" Name="$(var.DataBaseDirName)">
          <Component Id="DataBaseDir.dir" Guid="*">
               <CreateFolder/>
          </Component>
    </Directory>

1 个答案:

答案 0 :(得分:1)

  1. 无法解析名称cmd,而应使用引用的可执行文件名称:"cmd.exe"

  2. 应使用SetProperty,因为安装程序无法解析[DataBaseDir]

  3. 应设置序列execute

    <Property Id="RemoveDataDir" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="immediate" Return="ignore"/>
    <SetProperty Id="WixQuietExecCmdLine" Before="RemoveDataDir" Sequence="execute" Value='"cmd.exe" /c rmdir /s/q "[DataBaseDir]"'>1</SetProperty>