Inno Setup 如何从 AfterInstall 中排除单个文件
Inno Setup How to exclude a single file from AfterInstall
安装后,我想将字符串保存到 4 个文件中的 3 个,但目前正在将字符串保存到所有文件。如何排除名为网络的文件?我正在考虑另一个 if
语句,但不确定如何。该文件将是 {app}\configs\network.config
procedure MyBeforeInstall;
begin
if(FileExists(ExpandConstant(CurrentFileName))) then
begin
Exists := True;
end
else
begin
Exists := False;
end;
end;
procedure MyAfterInstall;
begin
if not(Exists) then
SaveStringToFile(ExpandConstant(CurrentFileName), #13#10 + 'SettingEnv ' + SettingEnv.Values[0] + #13#10, True);
MsgBox(ExpandConstant(CurrentFileName), mbInformation, MB_OK);
end;
假设您像这样使用 MyBeforeInstall
和 MyAfterInstall
:
[Files]
Source: "*.txt"; DestDir: "{app}"; \
BeforeInstall: MyBeforeInstall; AfterInstall: MyAfterInstall
那么你可以这样做:
[Files]
Source: "one.txt"; DestDir: "{app}"; \
BeforeInstall: MyBeforeInstall; AfterInstall: MyAfterInstall
Source: "two.txt"; DestDir: "{app}"; \
BeforeInstall: MyBeforeInstall; AfterInstall: MyAfterInstall
Source: "three.txt"; DestDir: "{app}"; \
BeforeInstall: MyBeforeInstall; AfterInstall: MyAfterInstall
Source: "but_not_this_one.txt"; DestDir: "{app}"
这也行:
[Files]
Source: "*.txt"; Excludes: "but_no_this_one.txt"; DestDir: "{app}"; \
BeforeInstall: MyBeforeInstall; AfterInstall: MyAfterInstall
Source: "but_not_this_one.txt"; DestDir: "{app}"
还有一个选项是:
procedure MyAfterInstall;
begin
if CompareText(ExtractFileName(CurrentFileName), 'but_not_this_one.txt') <> 0 then
begin
if not Exists then
SaveStringToFile(
CurrentFileName,
#13#10 + 'SettingEnv ' + SettingEnv.Values[0] + #13#10, True);
end;
MsgBox(CurrentFileName, mbInformation, MB_OK);
end;
(注意,在 CurrentFileName
上使用 ExpandConstant
没有意义,因为它的 return 值不包含任何常量)
安装后,我想将字符串保存到 4 个文件中的 3 个,但目前正在将字符串保存到所有文件。如何排除名为网络的文件?我正在考虑另一个 if
语句,但不确定如何。该文件将是 {app}\configs\network.config
procedure MyBeforeInstall;
begin
if(FileExists(ExpandConstant(CurrentFileName))) then
begin
Exists := True;
end
else
begin
Exists := False;
end;
end;
procedure MyAfterInstall;
begin
if not(Exists) then
SaveStringToFile(ExpandConstant(CurrentFileName), #13#10 + 'SettingEnv ' + SettingEnv.Values[0] + #13#10, True);
MsgBox(ExpandConstant(CurrentFileName), mbInformation, MB_OK);
end;
假设您像这样使用 MyBeforeInstall
和 MyAfterInstall
:
[Files]
Source: "*.txt"; DestDir: "{app}"; \
BeforeInstall: MyBeforeInstall; AfterInstall: MyAfterInstall
那么你可以这样做:
[Files]
Source: "one.txt"; DestDir: "{app}"; \
BeforeInstall: MyBeforeInstall; AfterInstall: MyAfterInstall
Source: "two.txt"; DestDir: "{app}"; \
BeforeInstall: MyBeforeInstall; AfterInstall: MyAfterInstall
Source: "three.txt"; DestDir: "{app}"; \
BeforeInstall: MyBeforeInstall; AfterInstall: MyAfterInstall
Source: "but_not_this_one.txt"; DestDir: "{app}"
这也行:
[Files]
Source: "*.txt"; Excludes: "but_no_this_one.txt"; DestDir: "{app}"; \
BeforeInstall: MyBeforeInstall; AfterInstall: MyAfterInstall
Source: "but_not_this_one.txt"; DestDir: "{app}"
还有一个选项是:
procedure MyAfterInstall;
begin
if CompareText(ExtractFileName(CurrentFileName), 'but_not_this_one.txt') <> 0 then
begin
if not Exists then
SaveStringToFile(
CurrentFileName,
#13#10 + 'SettingEnv ' + SettingEnv.Values[0] + #13#10, True);
end;
MsgBox(CurrentFileName, mbInformation, MB_OK);
end;
(注意,在 CurrentFileName
上使用 ExpandConstant
没有意义,因为它的 return 值不包含任何常量)