无法使用WIX更新"PATH"环境变量

use*_*683 9 installer windows-installer wix wix3.5

我使用以下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/>
Run Code Online (Sandbox Code Playgroud)

这最初工作,但现在它不更新环境变量.详细日志显示此操作的执行和返回值1.重新启动计算机后检查.在功能日志FeaturePublish For Feature3中,存在垃圾值,但安装成功.请求你的帮助......非常感谢....

小智 12

我认为您正在使用INSTALLLOCATION来表示使用INSTALLDIR.这是一个工作示例,它使用新应用程序的安装目录更新PATH环境var.

<Environment 
  Id="PATH" 
  Name="PATH" 
  Value="[INSTALLDIR]" 
  Permanent="yes" 
  Part="last" 
  Action="set" 
  System="yes" />
Run Code Online (Sandbox Code Playgroud)

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

  • [Wix 官方文档](https://www.firegiant.com/wix/tutorial/com-expression-syntax-miscellanea/environmentally-Friendly/) 用于“Environment”标签。 (2认同)