WindowsFolder属性作为exe地址的一部分不起作用 [英] WindowsFolder property as part of exe address is not working

查看:62
本文介绍了WindowsFolder属性作为exe地址的一部分不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我在网上找到的信息,尝试获得一个wix安装程序来终止进程,这似乎是一种方法:

Trying to get a wix installer to kill a process, from what I have found online it looks like this is the way to go:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="WindowsFolder" Name="WINDOWS"/>

<Property Id="QtExecCmdLine" Value='"[WindowsFolder]System32\taskkill.exe" /F /IM Foo.exe'/>
<CustomAction Id="KillTaskProcess" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="immediate" Return="ignore"/>

我在构建项目时遇到的问题将引发有关Windows属性的以下错误:

The problem I have is building the project will throw the following error complaining about the windows property:

The 'QtExecCmdLine' Property contains '[WindowsFolder]' in its value which is an illegal reference to another property.  If this value is a string literal, not a property reference, please ignore this warning.  To set a property with the value of another property, use a CustomAction with Property and Value attributes. 

我尝试使用[#WindowsFolder],它可以消除错误,但不能解决问题. 使用完整地址(C:\ Windows \ System32 \ taskkill.exe)代替该值确实可以,但是我想避免这种情况.

I have tried [#WindowsFolder] instead, it removes the error but does not solve the issue. Using the full address (C:\Windows\System32\taskkill.exe) instead for the value does work but I would like to avoid that.

推荐答案

我认为您无法以自己的方式引用目录(例如,"[WindowsFolder]").这种类型的注释用于引用属性的值.

WindowsInstaller已经提供了Public属性,它表示任何给定系统上的系统文件夹. 您可以在32上使用 [SystemFolder] 位计算机以获取 c:\ Windows \ System32 (在64位计算机上注意,这将为您提供 c:\ Windows \ SysWow64 ).
因此,在64位计算机上,您可以使用 [System64Folder] 将为您提供 c:\ Windows \ System32

I don't think you can reference a directory in the way that you are (e.g. "[WindowsFolder]"). This type of annotation is used to reference the values of properties.

WindowsInstaller does already provide a Public property which represents the System Folder on any given system. You can use [SystemFolder] on 32 bit machines to get c:\Windows\System32 (note on 64 bit machines this will give you c:\Windows\SysWow64).
Therefore, on 64 bit machines you can use [System64Folder] which will give you c:\Windows\System32

您的代码将如下所示

<Property Id="QtExecCmdLine" Value='"[SystemFolder]taskkill.exe" /F /IM Foo.exe'/>

<Property Id="QtExecCmdLine" Value='"[System64Folder]taskkill.exe" /F /IM Foo.exe'/>


我在支持32& amp;的安装程序包中执行类似的操作. 64位计算机.这使事情稍微复杂化了.
要解决此问题,请尝试使用您的代码进行以下操作:


I perform a similar operation in an installation package which supports both 32 & 64 bit machines. This complicates matters slightly.
To get around this I would try the following with your code:

<Property Id="TASKKILLFILEPATH"/>
<Property Id="QtExecCmdLine" Value='"[TASKKILLFILEPATH]" /F /IM Foo.exe'/>

然后,添加自定义操作以正确设置任务终止文件路径

Then, add a custom action to properly set the task kill file path

<CustomAction Id='SetTASKKILLFILEPATH32' Property='TASKKILLFILEPATH' Value='[SystemFolder]\taskkill.exe' Return='check' />
<CustomAction Id='SetTASKKILLFILEPATH64' Property='TASKKILLFILEPATH' Value='[System64Folder]\taskkill.exe' Return='check' />

在InstallExecuteSequence中,您可以根据系统类型运行适当的自定义操作:

In InstallExecuteSequence you can run the appropriate custom action based on the system type:

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

BTW VersionNT64 是WindowsInstaller提供的另一个属性.

这可能有点矫kill过正,我希望有其他人可以共享的简便方法,但是我知道这是一个可行的解决方案.希望至少,这会引导您进入正确的方向.

BTW VersionNT64 is yet another WindowsInstaller provided property.

This might be a bit overkill and I hope there is an easier way of doing this that someone else might share, but I know this to be a working solution. Hope this, at least, leads you in the right direction.

这篇关于WindowsFolder属性作为exe地址的一部分不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆