Inno Setup 要求对某个特定文件进行覆盖确认,无条件安装目录下的其他文件
Require overwrite confirmation for one specific file in Inno Setup, install other files in directory unconditionally
我有一个包含 84 个文件的目录 (Configurationfiles
)。其中一个文件包含用户将修改的数据 (UserData.json
)。该文件可能存在,也可能不存在,但如果存在,我不想丢失这些数据,并努力保持安装用户友好。
我正在尝试修改执行以下所有操作的现有安装脚本:
- 如果目录中没有文件,则全部复制
- 如果有文件覆盖除
UserData.json
之外的所有文件
- 如果
UserData.json
缺少复制默认值 UserData.json
- 如果存在
UserData.json
提示用户覆盖 UserData.json
,如果是则覆盖,如果不是则不要
目前所有的文件无论如何都会被复制,而且我从来没有收到覆盖的提示。这是我目前所拥有的:
#define ExcludeFiles "UserData.json"
Source: ..\..\PROV00701\BIN\*.*; Excludes: {#ExcludeFiles }; DestDir: {app}\BIN; \
Flags: ignoreversion recursesubdirs skipifsourcedoesntexist;
Source: ..\..\PROV00701\BIN\Configurationfiles\UserData.json; \
DestDir: {app}\BIN\Configurationfiles;
Flags: ignoreversion onlyifdoesntexist confirmoverwrite skipifsourcedoesntexist;
我想我的标志设置不正确。但我不确定。有人看到我哪里出错了吗?
您永远无法获得确认,因为 onlyifdoesntexist
阻止 confirmoverwrite
生效。
我认为您“无论如何都复制了所有文件”是正确的。当我测试你的脚本时,我得到:
2020-09-26 16:51:21.625 -- File entry --
2020-09-26 16:51:21.626 Dest filename: C:\Users\pimpo\AppData\Local\My Program\BIN\Configurationfiles\UserData.json
2020-09-26 16:51:21.626 Time stamp of our file: 2020-09-26 16:49:30.000
2020-09-26 16:51:21.626 Dest file exists.
2020-09-26 16:51:21.626 Skipping due to "onlyifdoesntexist" flag.
如果您删除 onlyifdoesntexist
,您的脚本应该会执行您想要的操作。
2020-09-26 16:57:41.066 -- File entry --
2020-09-26 16:57:41.067 Dest filename: C:\Users\pimpo\AppData\Local\My Program\BIN\Configurationfiles\UserData.json
2020-09-26 16:57:41.067 Time stamp of our file: 2020-09-26 16:49:30.000
2020-09-26 16:57:41.067 Dest file exists.
2020-09-26 16:57:41.067 Time stamp of existing file: 2020-09-26 16:49:30.000
2020-09-26 16:57:41.067 Message box (Yes/No):
C:\Users\pimpo\AppData\Local\My Program\BIN\Configurationfiles\UserData.json
The file already exists.
Would you like Setup to overwrite it?
2020-09-26 16:57:43.055 User chose Yes.
2020-09-26 16:57:43.055 Installing the file.
2020-09-26 16:57:43.062 Successfully installed the file.
您可能还想删除 ignoreversion
,因为它对 .json
文件没有影响。这可能会使其他人感到困惑。 skipifsourcedoesntexist
也有疑问。
我有一个包含 84 个文件的目录 (Configurationfiles
)。其中一个文件包含用户将修改的数据 (UserData.json
)。该文件可能存在,也可能不存在,但如果存在,我不想丢失这些数据,并努力保持安装用户友好。
我正在尝试修改执行以下所有操作的现有安装脚本:
- 如果目录中没有文件,则全部复制
- 如果有文件覆盖除
UserData.json
之外的所有文件
- 如果
UserData.json
缺少复制默认值UserData.json
- 如果存在
UserData.json
提示用户覆盖UserData.json
,如果是则覆盖,如果不是则不要
目前所有的文件无论如何都会被复制,而且我从来没有收到覆盖的提示。这是我目前所拥有的:
#define ExcludeFiles "UserData.json"
Source: ..\..\PROV00701\BIN\*.*; Excludes: {#ExcludeFiles }; DestDir: {app}\BIN; \
Flags: ignoreversion recursesubdirs skipifsourcedoesntexist;
Source: ..\..\PROV00701\BIN\Configurationfiles\UserData.json; \
DestDir: {app}\BIN\Configurationfiles;
Flags: ignoreversion onlyifdoesntexist confirmoverwrite skipifsourcedoesntexist;
我想我的标志设置不正确。但我不确定。有人看到我哪里出错了吗?
您永远无法获得确认,因为 onlyifdoesntexist
阻止 confirmoverwrite
生效。
我认为您“无论如何都复制了所有文件”是正确的。当我测试你的脚本时,我得到:
2020-09-26 16:51:21.625 -- File entry --
2020-09-26 16:51:21.626 Dest filename: C:\Users\pimpo\AppData\Local\My Program\BIN\Configurationfiles\UserData.json
2020-09-26 16:51:21.626 Time stamp of our file: 2020-09-26 16:49:30.000
2020-09-26 16:51:21.626 Dest file exists.
2020-09-26 16:51:21.626 Skipping due to "onlyifdoesntexist" flag.
如果您删除 onlyifdoesntexist
,您的脚本应该会执行您想要的操作。
2020-09-26 16:57:41.066 -- File entry --
2020-09-26 16:57:41.067 Dest filename: C:\Users\pimpo\AppData\Local\My Program\BIN\Configurationfiles\UserData.json
2020-09-26 16:57:41.067 Time stamp of our file: 2020-09-26 16:49:30.000
2020-09-26 16:57:41.067 Dest file exists.
2020-09-26 16:57:41.067 Time stamp of existing file: 2020-09-26 16:49:30.000
2020-09-26 16:57:41.067 Message box (Yes/No):
C:\Users\pimpo\AppData\Local\My Program\BIN\Configurationfiles\UserData.jsonThe file already exists.
Would you like Setup to overwrite it?
2020-09-26 16:57:43.055 User chose Yes.
2020-09-26 16:57:43.055 Installing the file.
2020-09-26 16:57:43.062 Successfully installed the file.
您可能还想删除 ignoreversion
,因为它对 .json
文件没有影响。这可能会使其他人感到困惑。 skipifsourcedoesntexist
也有疑问。