如何将文件安装到 Installshield Installscript-MSI 项目中注册表项/值所指向的目录?

发布于 2024-07-18 14:56:37 字数 486 浏览 6 评论 0原文

我的安装中的文件之一需要复制到用户目标计算机上的注册表项/值对所指向的位置。

现在,我有一种笨拙的解决方案,我将文件设置为复制到组件视图中的 [TempFolder],然后在我的 OnFirstUIBefore() 函数中使用一些自定义 InstallScript 代码,该代码从注册表中获取值,然后执行[TempFolder] 上的 MSIGetProperty,最后将 [TempFolder] 中的 CopyFile() 复制到我们之前从注册表中获取的路径中。

这可行,但有点麻烦。 一位同事说,他认为我应该能够对像 MY_RSRC_DIR 这样的自定义属性名称执行 MSISetProperty,然后以某种方式在“组件”窗格中使用该自定义属性将文件复制到正确的位置。

我可以在 OnBegin() 函数中执行 MSISetProperty,但尝试将该属性插入到 Components 视图中是我还无法完成的工作。

有人这样做过吗?如果是,怎么做的?

One of the files in my installation needs to get copied into a location pointed to by a registry key/value pair on the user's destination machine.

Right now, I have a kind of kludgy solution where I have the files set to copy to [TempFolder] in the Components view, and then some custom InstallScript code in my OnFirstUIBefore() function which grabs the value from the registry, then does an MSIGetProperty on [TempFolder] and finally a CopyFile() from [TempFolder] into the path we grabbed from the registry previously.

This works but is all a bit cumbersome. A coworker says that he thinks I SHOULD be able to do an MSISetProperty on a custom property name like MY_RSRC_DIR and then somehow use that custom property in the Components pane to get the file copied to the correct place.

I can get as far as doing the MSISetProperty in an OnBegin() function, but trying to plug that property into the Components view is something I've not been able to get working yet.

Has anyone done this, and if so, how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ㄟ。诗瑗 2024-07-25 14:56:37

在 InstallScript MSI 项目中,您应该采用 MSI 方法。 创建一个辅助文件夹(例如将其添加到“文件和文件夹”视图),然后将文件添加到其中。 确保找到它的目录属性(例如NEWFOLDER1;确保它全部大写)。 如果需要,您可以编辑目录表以使其成为 TARGETDIR 的子项,但这是可选的,并且如果注册表搜索失败,可能会导致文件被放置在 [WindowsVolume] 下,因此最好将其保留为 INSTALLDIR 的子项。

然后,如果您可以在成本计算之前找到该目录(即在 CostInitialize 之前,即 OnBegin 之前),则可以使用系统搜索、SetProperty 自定义操作(类型 51)或 MsiSetProperty() 设置属性(例如 NEWFOLDER1)。 如果您必须在成本计算后找到它,则需要使用 SetDirectory 自定义操作(类型 35)或 MsiSetTargetPath(),因为该属性将不再更新目录。

这样,Windows Installer 将为您跟踪文件位置,并且卸载应该可以正常工作。

In an InstallScript MSI project, you should take the MSI approach. Create an auxiliary folder (for example adding it to the Files and Folders view), and add your files to it. Make sure to find out its directory property (something like NEWFOLDER1; make sure it's all upper-case). If you want, you can edit the Directory table to make this a child of TARGETDIR, but that's optional and can result in files being placed under [WindowsVolume] if the registry search fails, so it's probably best to leave it as a child of INSTALLDIR.

Then if you can locate the directory before costing (i.e. before CostInitialize, which OnBegin would be), you can set the property (e.g. NEWFOLDER1) with a System Search, SetProperty custom action (type 51), or MsiSetProperty(). If you must find it after costing, you'll need to use either a SetDirectory custom action (type 35), or MsiSetTargetPath(), as the property will no longer update the directory.

This way Windows Installer will track the file location for you and uninstall should work properly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文