如何获取正在安装的文件的文件名?
如何获取正在安装的文件的文件名?
我想检查正在安装的文件是否已经在目标文件夹中,并将现有文件重命名为其他名称。有没有办法让我们知道正在安装的文件名? (大约 OnMoving() 左右?)。
注意:我正在使用 InstallScript MSI - InstallShield 2011 Premier
How to get the file name of the file which is being installed?
I want to check if the file being installed is already at the destination folder and rename the existing one to some other name. Is there a way where we get to know the file name of which is being installed? (around OnMoving() or so?).
Note: I am using InstallScript MSI - InstallShield 2011 Premier
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试使用自定义操作读取软件包将在运行时安装的文件的文件名,然后检查安装目录是否包含具有匹配名称的另一个文件。
以下是可以在安装时访问 MSI 数据库的自定义操作的一些示例:
http://msdn.microsoft.com/en-us/library/Aa372865
You can try to read the filenames of the files that your package will install at run-time using a custom action and then check the install directory if it contains another file with a matching name.
Here are some examples of custom actions that can access the MSI database at install-time:
http://msdn.microsoft.com/en-us/library/Aa372865
虽然我认为您可以在纯 InstallScript 项目中基于每个文件拦截文件安装,但您无法在基于 Windows Installer 的 InstallScript MSI 项目中执行此操作。这是因为 Windows Installer 不提供这种挂钩。因此,如果您想做这样的事情,您需要提前确定哪些文件将被覆盖,并在此时执行您想要的操作,而不是等待每个文件的事件。
While I think you can intercept file installation on a per-file basis in a pure InstallScript project, you cannot do it in the Windows Installer based InstallScript MSI project. This is because Windows Installer doesn't give that kind of hook. So if you want to do something like this, you will need to figure out which files will be overwritten ahead of time, and do what you want at that point instead of waiting for a per-file event.