【问题标题】:Not able to expand property SourceDir in Custom Action ExeCommand无法在自定义操作 ExeCommand 中展开属性 SourceDir
【发布时间】:2019-07-29 06:19:52
【问题描述】:

我正在尝试在我的自定义操作中扩展 Directory SourceDir。

我现在的作品是这样的……

<CustomAction Id="CopyShortcutBack" Directory="APPLICATIONFOLDER" 
          Execute="commit" Impersonate="yes" Return="ignore" 
ExeCommand='cmd.exe /k copy "[APPLICATIONFOLDER]MikeySourceToExcelShortcut.lnk" &quot;\&quot;[SourceDir] \&quot;&quot; ' 
              />

""" 和 "\&quot" 是在 stackoverflow 中阅读此问题后尝试使其工作... Not able to send Wix SourceDir path with spaces to custom action ExeCommand

但是,没有任何效果。无论有没有任何引号组合,SourceDir 都不会被扩展。请注意,我的 ExeCommand 还包括正在扩展的 [APPLICATIONFOLDER]。

wix 运行的命令,我在另一个打开的 cmd.exe 中通过wmic 获得的是...

cmd.exe /k copy "C:\Users\Mikey\AppData\Local\Apps\Mikey\Personal\Shortcut Test\MikeySourceToExcelShortcut.lnk" "\" \"" 

还要注意 [APPLICATIONFOLDER] 的扩展确实有一个空格,所以我不会怀疑空格是 [SourceDir] 内部的问题。

如果相关,请从我的 .wsx 文件中提取更多代码。我评论了我的一些失败尝试...

   <Shortcut Id="MikeySourceToExcelShortcut"
            Name="MikeySourceToExcelShortcut"
            Description="For finding the installation directory"
            Target="[APPLICATIONFOLDER]"
            WorkingDirectory="SourceDir"/>


</Component>


<!--
The simple way I think it should be...
          ExeCommand='cmd.exe /k copy "[APPLICATIONFOLDER]MikeySourceToExcelShortcut.lnk" "[SourceDir]" ' 



ExeCommand='cmd.exe /k copy "[APPLICATIONFOLDER]MikeySourceToExcelShortcut.lnk" "&quot;[SourceDir]&quot;" ' 
gave...
cmd.exe /k copy "C:\Users\Mikey\AppData\Local\Apps\Mikey\Personal\Shortcut Test\MikeySourceToExcelShortcut.lnk" """" 


ExeCommand='cmd.exe /k copy "[APPLICATIONFOLDER]MikeySourceToExcelShortcut.lnk" "\&quot;[SourceDir]\&quot;" ' 
gave...
cmd.exe /k copy "C:\Users\Mikey\AppData\Local\Apps\Mikey\Personal\Shortcut Test\MikeySourceToExcelShortcut.lnk" "\"\"" 

ExeCommand='cmd.exe /k copy "[APPLICATIONFOLDER]MikeySourceToExcelShortcut.lnk" &quot;\&quot; [SourceDir]\&quot;&quot; ' 
gave...
cmd.exe /k copy "C:\Users\Mikey\AppData\Local\Apps\Mikey\Personal\Shortcut Test\MikeySourceToExcelShortcut.lnk" "\"\"" 


ExeCommand='cmd.exe /k copy "[APPLICATIONFOLDER]MikeySourceToExcelShortcut.lnk" &quot;\&quot;[SourceDir] \&quot;&quot; ' 
gave...
cmd.exe /k copy "C:\Users\Mikey\AppData\Local\Apps\Mikey\Personal\Shortcut Test\MikeySourceToExcelShortcut.lnk" "\" \"" 
-->

<CustomAction Id="CopyShortcutBack" Directory="APPLICATIONFOLDER" 
              Execute="commit" Impersonate="yes" Return="ignore" 
ExeCommand='cmd.exe /k copy "[APPLICATIONFOLDER]MikeySourceToExcelShortcut.lnk" &quot;\&quot;[SourceDir] \&quot;&quot; ' 
              />

<InstallExecuteSequence>
  <Custom Action="CopyShortcutBack" After="InstallInitialize" />
</InstallExecuteSequence>

请注意,快捷方式本身已将 WorkingDirectory 设置为“SourceDir”,这也可以使用,即 SourceDir 正在此处展开​​。

我会欢迎任何想法来实现这个工作。我不在乎是否必须创建另一个属性来扩展 SourceDir 然后引用它。

顺便说一句,我最初也尝试通过 Directory 属性将快捷方式直接插入 SourceDir。不幸的是,它没有用。如果这可行,那就太好了,然后我就可以绕过所有这些自定义操作的东西。看起来 Microsoft 不允许我尝试实现的功能(将快捷方式放回我的安装目录)。

【问题讨论】:

    标签: windows wix


    【解决方案1】:

    我找到了一个名为 ResolveSource 的元素...

    &lt;ResolveSource Before="CostFinalize" Suppress="no" /&gt;

    我找到答案后找到了这个链接。
    Why I am getting blank value for SourceDir in a managed Custom Action in WIX?

    由于某种原因,当我不知道解决方案时,我发现所有在谷歌上不起作用的线程。只有在我解决之后,我才能找到具有正确解决方案的其他线程。很神秘。其他问题也会出现这种情况。

    【讨论】:

      猜你喜欢
      • 2021-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-16
      • 2021-06-05
      相关资源
      最近更新 更多