维克斯工具集。如何使用$(env.windir)?

Wix Toolkit. How to use $(env.windir)?

我需要使用 tskill.exe 杀死一个 运行ning 控制台应用程序,该应用程序在后台 运行ning 但是当我 defive $(env.windir)\system32 我得到以下错误。

CustomAction/@Directory 属性的值 'C:\WINDOWS' 不是合法的标识符。标识符可以包含 ASCII 字符 A-Z、a-z、数字、下划线 (_) 或句点 (.)。每个标识符必须以字母或下划线开头。

而我写给 运行 tskill.exe 的 CustomAction 是:

<CustomAction Id="TaskKill" Impersonate="yes" Return="ignore" Directory="$(env.windir)" ExeCommand='"\system32\tskill.exe" /F /IM MyConsoleApp' TerminalServerAware="yes" Execute="deferred"/>

实现此目标的正确方法是什么?

编辑: 我意识到我用错了方法。这是我现在拥有的:

    <Property Id="TASKKILLFILEPATH"/>
    <Property Id="QtExecCmdLine" Value='"[TASKKILLFILEPATH]" /F /IM MyConsoleApp.exe'/>
    <CustomAction Id='SetTASKKILLFILEPATH32' Property='TASKKILLFILEPATH' Value='[SystemFolder]taskkill.exe' Return='check' />
    <CustomAction Id='SetTASKKILLFILEPATH64' Property='TASKKILLFILEPATH' Value='[System64Folder]taskkill.exe' Return='check' />

<InstallExecuteSequence>
      <RemoveExistingProducts Before="InstallInitialize" />

      <Custom Action='SetTASKKILLFILEPATH64' Before='AppSearch'>VersionNT64</Custom>
      <Custom Action='SetTASKKILLFILEPATH32' Before='AppSearch'>Not VersionNT64</Custom>
    </InstallExecuteSequence>

还是不行。

我想做的是在安装或卸载开始之前终止进程 (MyConsoleApp.exe)。

代码有什么问题?

这是我的做法。

<Property Id="cmdline">taskkill.exe /F /IM VClassConsole.exe</Property>

<CustomAction Id="SystemShell" Execute="deferred" Directory="TARGETDIR" ExeCommand='[cmdline]' Return="ignore" Impersonate="no"/>

<InstallExecuteSequence>
  <Custom Action="SystemShell" After="InstallInitialize"/>
</InstallExecuteSequence>