NSIS与InstalldirRegKey玩 [英] NSIS play with InstalldirRegKey

查看:2657
本文介绍了NSIS与InstalldirRegKey玩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从NSIS的文档,我们有

From NSIS documentation, we have

root_key子项KEY_NAME 这个属性告诉安装程序
  检查注册表字符串,并使用它的安装目录如果
  字符串是有效的。如果此属性为present,它将覆盖
  INSTALLDIR属性如果该注册表项是有效的,否则会
  回落到INSTALLDIR缺省值。

root_key subkey key_name This attribute tells the installer to check a string in the registry, and use it for the install dir if that string is valid. If this attribute is present, it will override the InstallDir attribute if the registry key is valid, otherwise it will fall back to the InstallDir default.

所以,如果我有一个 .nsi 文件这些行:

So, if I have these lines in a .nsi file:

InstallDir "D:\myFolder\myFile"

InstallDirRegKey HKCU "Software\${PRODUCT_COMPANY}\${PRODUCT_NAME}" "Install_Dir"

我明白,我把我的安装目录 D:\\ MyFolder文件\\ MYFILE 作为默认目录,但如果 SOFTWARE \\ $ {PRODUCT_C​​OMPANY} \\ $ {PRODUCT_NAME} 是一个有效的路径,那么我会用它来代替。这是否正确?

I understand that I set my install directory to D:\myFolder\myFile as default directory, but if Software\${PRODUCT_COMPANY}\${PRODUCT_NAME} is a valid path, then I will use it instead. Is that correct?

从另一个<一个href=\"http://stackoverflow.com/questions/5896463/nsis-silent-install-started-via-$c$c?rq=1\">post,据我所知, InstallDirRegKey 指令用来覆盖在相同的位置previous安装。它是如何工作的更多precisely?如果我有以下,

From another post, I understand that the InstallDirRegKey instruction is used to overwrite previous installation at same location. How is it working more precisely? If I have the following,

InstallDir "D:\myFolder\myFile"

InstallDirRegKey HKCU "D:\myFolder\myFile" "Install_Dir"

将由NSIS脚本生成一个新的 .exe文件文件覆盖previous吗?还是意味着该可执行文件将覆盖previous呢?

will a new .exe file generated by the NSIS script overwrite the previous one? Or does it mean that the executable will overwrite the previous one?

推荐答案

InstallDirRegKey只能从注册表中读取,它永远不会写。

InstallDirRegKey only reads from the registry, it never writes.

在你的 .onInit 执行NSIS做:

Before your .onInit is executed NSIS does:


  1. 如果 INSTALLDIR 设置,该路径被复制到 $ INSTDIR

  2. 如果 InstallDirRegKey 设置和注册表项存在,从注册表路径(与文件名中删除)复制到 $ INSTDIR

  1. If InstallDir is set, that path is copied to $Instdir
  2. If InstallDirRegKey is set and the registry key exists, the path from the registry (With the filename removed) is copied to $Instdir

所以,如果你想InstallDirRegKey有任何影响的用户运行安装程序,下一次你必须将其指向您的安装在你的部分之一创建密钥。它可以在你的卸载键或类似 HKLKM一个专用键\\ SOFTWARE \\我的公司\\我的应用

So if you want InstallDirRegKey to have any effect the next time a user runs the installer you must point it to a key that your installer creates in one of your sections. It can be the UninstallString command in your uninstall key or a application specific key like HKLKM\Software\My Company\My App.

这整点是,当用户重新安装或安装您的应用程序将被安装在同一文件夹中的新版本(覆盖/升级现有的安装)。

The whole point of this is that when the user re-installs or installs a new version of your app it will be installed in the same folder (overwriting/upgrading the existing install).

这篇关于NSIS与InstalldirRegKey玩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆