如何在 NullSoft 静默安装过程中检查可用空间?
在静默安装模式下,不会使用 询问用户安装目标PageEx 目录
,因此函数 DirVerify
和 GetInstDirError
从未被调用。
这也适用于出于与上述相同的原因对安装目标进行硬编码的安装(一个坏主意):永远不会调用 PageEx 目录
。
In silent install mode the user is not asked about the installation target with the PageEx directory
, and therefore the functions DirVerify
and GetInstDirError
are never called.
This is also applicable to installs that hardcode the installation target (a bad idea) for the same reason as above: the PageEx directory
is never invoked.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的示例代码没问题,但在 Win9x 上调用 ${DriveSpace} 可能会失败。 我还删除了指定部分 id 的需要,
我只做了有限的测试,希望没有错误:)
Your sample code is ok, but calling ${DriveSpace} on Win9x could fail. I also removed the need to specify the section id's
I only did limited testing, hopefully there are no bugs :)
我在 NSIS 中编写了一个名为
CheckFreeSpace
的函数来执行此操作。 不幸的是,它有以下限制:CheckFreeSpace
以添加每个部分。 我找不到迭代将使用 NSIS 安装的所有部分的方法。${DriveSpace}
需要驱动器号,而不是任意目录的路径。 驱动器号字符串使用StrCpy $instdrive $INSTDIR 3
计算。 如果$INSTDIR
变量是相对路径或不以C:\
等字符串开头,则此操作将会失败。MessageBox
。 您可以通过在语句末尾添加/SD IDOK
来抑制MessageBox
,但随后用户不会收到安装失败的通知:我找不到方法从 NSIS 发送到stdout
。 也许安装程序的返回代码就足够了?\tmp
目录中。另外,在下面的实现中,
CheckFreeSpace
对于安装后的可用空间有一个硬编码值。 显然,这是可以参数化的。这是一个示例安装程序:
I wrote a function called
CheckFreeSpace
in NSIS to do this. Unfortunately it has the following limitations:CheckFreeSpace
to add each section, by knowing each variable that each section id was written into. I can't find a way of iterating over all sections that will be installed using NSIS.${DriveSpace}
requires a drive letter, not a path to an arbitrary directory. The drive letter string is computed withStrCpy $instdrive $INSTDIR 3
. If the$INSTDIR
variable is a relative path or does not begin with a string such asC:\
, this will fail.MessageBox
. You can suppress theMessageBox
by adding/SD IDOK
at the end of the statement, but then the user is not informed of the installation failure: I can't find a way to emit tostdout
from NSIS. Perhaps the return code from the installer is enough?\tmp
directory.Also, in my implementation below,
CheckFreeSpace
has a hardcoded value for the space free after installation. Obviously that can be parameterized.Here it is within a sample installer:
您有静默安装的示例脚本吗?
Do you have a sample script for silent install?