如何找到运行msi安装程序的位置

san*_*_bl 5 wix

谁能告诉我如何找到运行msi安装程序的位置。

例如,我Sample.msi在桌面上的InstallerExample文件夹中有我的and Manuals文件夹。

我需要这些信息,以便可以在File / @ Source中使用它,就像下面给出的那样。

<File Id="MyFileId" Name="MyFile" Source="[SourceDir]Manuals" KeyPath="yes" >
Run Code Online (Sandbox Code Playgroud)

SourceDir 应该有价值 C:\Users\bla\Desktop\InstallerExample\Manuals

如果有人可以帮助我,那就太好了。

Nat*_*arr 2

我遇到了同样的问题,因为我希望自定义操作从 MSI 所在位置读取文件,所以我需要路径。我能够使用找到它

TARGETDIR
Run Code Online (Sandbox Code Playgroud)

根据 MSDN 文档 TARGETDIR 是

the root destination directory for the installation
Run Code Online (Sandbox Code Playgroud)

另外根据 MSDN,SourceDir 是

the root directory that contains the source cabinet file or the source file tree of the installation package
Run Code Online (Sandbox Code Playgroud)

因此 SourceDir 属性指向一个真实的目录:您的 MSI 文件所在的目录。使用 msiexec /lvx* installer.log installer.msi 安装时,您可以在安装程序日志中看到此信息。

但是,由于某种原因,在解析 TARGETDIR 时 SourceDir 被完全忽略。TARGETDIR 必须显式设置(例如在命令行上),否则解析为ROOTDRIVE。如果未显式设置 ROOTDRIVE,则它是具有最多可用空间的驱动器的根目录。