11

我已使用以下 wix 片段来更新“PATH”环境变量。

<DirectoryRef Id="MyDir">
   <Component Id ="setEnviroment" 
                           Guid=" xxxxx">
            <CreateFolder />
             <Environment Id="SET_ENV"
                                       Action="set"                                                                                          
                                         Name="PATH"
                                        Part="last"       
                                       Permanent="no" 
                                        System="yes" 
                         Value="[INSTALLLOCATION]" />
       </Component>
</DirectoryRef>
<Feature Id="Feature3" Title="3Feature"   
             Level="1" 
              Absent="disallow"
               AllowAdvertise="no">
           <ComponentRef Id="setEnviroment"/>
</Feature>
<InstallExecuteSequence>
    <WriteEnvironmentStrings/>
<InstallExecuteSequence/>

这最初是有效的,但现在它不会更新环境变量。详细日志显示此操作的执行并返回值 1。重新启动机器后检查。在操作 FeaturePublish For Feature3 的日志中有垃圾值,但安装成功。请求您的帮助......非常感谢......

4

2 回答 2

15

我认为您正在使用 INSTALLLOCATION,您的意思是使用 INSTALLDIR。这是一个使用新应用程序的安装目录更新 PATH 环境变量的工作示例。

<Environment 
  Id="PATH" 
  Name="PATH" 
  Value="[INSTALLDIR]" 
  Permanent="yes" 
  Part="last" 
  Action="set" 
  System="yes" />

如果确实打算使用 INSTALLLOCATION 并在其他地方定义它,那么请发布您的其余代码,我们将进一步深入兔子洞。

于 2012-07-11T13:18:04.733 回答
0

我需要使用 INSTALLFOLDER 来让它工作。

<Environment 
  Id="PATH" 
  Name="PATH" 
  Value="[INSTALLFOLDER]" 
  Permanent="yes" 
  Part="last" 
  Action="set" 
  System="yes" />
于 2018-06-29T13:54:52.307 回答