Wix:在自定义操作目录中使用computername

时间:2014-05-21 14:26:36

标签: batch-file wix installation

我想使用运行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 

所以computername是空的......

+++ 最后,感谢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>

1 个答案:

答案 0 :(得分:1)

您应该使用ComputerName代替COMPUTERNAME

因此,您可以使用自定义操作&#34;

将ComputerName复制到COMPUTERNAME名称
<CustomAction Id="SetMachineName" Property="COMPUTERNAME" Value="[ComputerName]" Execute="immediate"></CustomAction>
相关问题