【问题标题】:Wix: use computername in custom action directoryWix:在自定义操作目录中使用计算机名
【发布时间】:2014-05-21 23:27:34
【问题描述】:

我想在自定义操作中使用运行 msi 的计算机的名称来执行一个批处理文件,该批处理文件与 msi 文件一起部署在与计算机名称相同的目录中。

例如,在名为“MyServer”的机器上安装 msi 后,目录如下所示:C:\program files\MyApp\Config\MyServer\Config.bat

我想在安装后运行 Config.bat 文件,所以我想出了自定义操作

<CustomAction
     Id="CONFIGURE"
     Directory="INSTALLFOLDER\Config\[COMPUTERNAME]"
     ExeCommand="Configure.bat"
     Execute="deferred"
     Return="ignore" />

  <InstallExecuteSequence>
     <Custom Action="CONFIGURE"
             After="InstallFiles" />
  </InstallExecuteSequence>

现在我需要真正的计算机名而不是 [COMPUTERNAME]。

或者是这样的:

  <CustomAction
     Id="CONF"
     Directory="INSTALLFOLDER"
     ExeCommand="\Config\[COMPUTERNAME]\Configure.bat"
     Execute="deferred"
     Return="ignore"
     HideTarget="no"
     Impersonate="no" />

上面的例子看起来更好,但在安装时日志文件告诉我:

Action: CONF, location: c:\Program Files (x86)\MyApp\, command: \Config\\Configure.bat 

所以计算机名是空的...

+++ 最后感谢 Dusan Plavak,解决方案是:

  <CustomAction
     Id="CONF"
     Directory="INSTALLFOLDER"
     ExeCommand="\Config\[ComputerName]\Configure.bat"
     Execute="deferred"
     Return="ignore"
     HideTarget="no"
     Impersonate="no" />
  <InstallExecuteSequence>
     <Custom Action="CONF"
             After="InstallFiles" />
  </InstallExecuteSequence>

【问题讨论】:

    标签: batch-file wix installation


    【解决方案1】:

    您应该使用ComputerName 而不是COMPUTERNAME

    例如,您可以使用自定义操作将 ComputerName 复制到 COMPUTERNAME 名称"

    <CustomAction Id="SetMachineName" Property="COMPUTERNAME" Value="[ComputerName]" Execute="immediate"></CustomAction>
    

    【讨论】:

    • 这对我有用。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多