我必须等待 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/