1

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

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

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

我可以在 OnBegin() 函数中执行 MSISetProperty,但是尝试将该属性插入到组件视图中是我还不能开始工作的事情。

有没有人这样做过,如果有,怎么做?

4

1 回答 1

1

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.

于 2009-05-01T18:52:20.297 回答