简体   繁体   English

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

[英]How can I install a file to a directory pointed to by a registry key/value in an Installshield Installscript-MSI project?

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. 现在,我有一种解决方案,其中将文件设置为要复制到“组件”视图中的[TempFolder],然后在我的OnFirstUIBefore()函数中添加一些自定义InstallScript代码,该函数从注册表中获取值,然后执行[TempFolder]上的MSIGetProperty,最后是[TempFolder]上的CopyFile()到我们之前从注册表中获取的路径。

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. 一位同事说,他认为我应该能够对自定义属性名称(如MY_RSRC_DIR)执行MSISetProperty,然后以某种方式在“组件”窗格中使用该自定义属性来将文件复制到正确的位置。

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. 我可以在OnBegin()函数中完成MSISetProperty的工作,但是尝试将该属性插入到“组件”视图中是我还无法开始的工作。

Has anyone done this, and if so, how? 有没有人做过,如果是这样,怎么做?

In an InstallScript MSI project, you should take the MSI approach. 在InstallScript MSI项目中,您应该采用MSI方法。 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). 确保找出其目录属性(类似于NEWFOLDER1;确保它们全部为大写)。 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. 如果需要,可以编辑Directory表以使其成为TARGETDIR的子级,但这是可选的,如果注册表搜索失败,则可能导致文件放置在[WindowsVolume]下,因此最好将其保留为INSTALLDIR的子级。

Then if you can locate the directory before costing (ie before CostInitialize, which OnBegin would be), you can set the property (eg NEWFOLDER1) with a System Search, SetProperty custom action (type 51), or MsiSetProperty(). 然后,如果您可以在成本核算之前(即在CostInitialize之前,即OnBegin之前)找到目录,则可以使用系统搜索,SetProperty自定义操作(类型51)或MsiSetProperty()来设置属性(例如NEWFOLDER1)。 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. 如果必须在成本核算后找到它,则需要使用SetDirectory自定义操作(类型35)或MsiSetTargetPath(),因为该属性将不再更新目录。

This way Windows Installer will track the file location for you and uninstall should work properly. 这样Windows Installer会为您跟踪文件位置,并且卸载应能正常进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM