inno-setup - 自动重试删除要使用 Inno Setup 替换的文件

标签 inno-setup

我必须等待 5-10 秒,然后在 PlazSales 销售点软件的 DBNetServices 上单击重试。有没有办法让它自动等待至少一段时间?

错误:

An error occurred while trying to replace the existing file: DeleteFile failed; code 5; Access is denied. Click retry to try again...

[Setup]
CloseApplications=yes   

[Files]
Source: {#AutoBackupNetwork}\DBNetService.exe; DestDir: {app}\server; \
    Flags: IgnoreVersion overwritereadonly

最佳答案

您可以实现删除文件的自定义逻辑,例如:

[Files]
Source: {#AutoBackupNetwork}\DBNetService.exe; DestDir: {app}\server; \
    Flags: IgnoreVersion overwritereadonly; BeforeInstall: DeleteWithRetry
[Code]

procedure DeleteWithRetry;
var
  Path: string;
  Timeout: Integer;
  Step: Integer;
begin
  Path := ExpandConstant('{app}\server\DBNetService.exe');
  if FileExists(Path) then
  begin
    Log(Format('%s exists, will try to delete', [Path]));
    Timeout := 5000;
    Step := 100;
    while (Timeout > 0) and (not DeleteFile(Path)) do
    begin
      Log(Format('Failed to delete %s, will try again in %d ms', [Path, Step]));
      Sleep(Step);
      Timeout := Timeout - Step;
    end;
  end;
end;

关于inno-setup - 自动重试删除要使用 Inno Setup 替换的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48600028/

相关文章:

windows - 从虚拟化的 Windows 注册表中读取 key

macos - 有没有类似于 Inno Setup 的 OS X 安装程序(最好是免费的)?

animation - 视频文件(带 Alpha)作为闪屏?

inno-setup - 连接字符串和整数失败,错误为 "Type mismatch"

inno-setup - 如何在 Inno Setup 中为 OutputBaseFilename 填充版本组件

inno-setup - Inno Setup Pascal 脚本中的 "if"语句是什么意思

windows - Inno Setup 始终在 Pascal Script 代码中以 32 位模式启动 PowerShell

inno-setup - 如何在程序运行时且仅在用户确认关闭并卸载后才将其卸载 - Inno Setup

java - 是否可以使用 ant 自动创建 inno 安装包?

inno-setup - 在 Inno Setup 中更改任务列表框和其他控件的背景颜色