Archive: NSISdl and Antivirus delay


NSISdl and Antivirus delay
Hi

I'm using a simple method to download a rar file and extract it using NSISdl and nsExec::ExecToLog. Worked great so far but I found a situation where it seems the antivirus installed on the target machine is locking the file a bit too long and thus, the installer doesn't find it where it should be.

Some lines

NSISdl::download 'http://www.xxx.com/file.rar' 'C:\install\file.rar'
...
...
nsExec::ExecToLog '"C:\install\unrar.exe" x -y "C:\install\file.rar" "C:\install"'


When looking in the folder, the file is not there so the unrar attempt fails. But the file was downloaded, the installer is doing his thing and showing the progression of the download.

What told me that the antivirus might be the critter is when I ask the client to manually download the rar file (90Mb) and save it in the destination folder (so that the installer wouldn't need to download it). We noticed that the antivirus took a 10 seconds or so after the download before putting the file in the folder.

This has happened only on a few setups and the antivirus was NOD32 in this case. No message or anything from it. My installer downloads 2 different files sometimes and the second file did not have a problem but it is much smaller so maybe the AV took no time to scan it and put it in the destination folder.

Not much to add I'm afraid and didn't find much of a workaround and since it only happened once for 1 client, I can live with the trouble for now but if someone had the same issue and found a solution, I'm open to suggestions.

;)

You just need a For loop to loop 10-20 times with a Sleep 1000 and if the file is found, break out of the loop. After the loop if the file is not found then something must be wrong (show an error or something).

Stu


You can use a loop with IfFileExists.
Like:

NSISdl::download 'http://www.xxx.com/file.rar' 'C:\install\file.rar'
...
...
loop:
(Maybe set a limit and/or delay here)
IfFileExists "C:\install\file.rar" install loop
install:
nsExec::ExecToLog '"C:\install\unrar.exe" x -y "C:\install\file.rar" "C:\install"'

Yes and thanks to both of you, just fiddling now to find the right syntax as to set the limit so that it doesn't infinite loop.

But until then, this is the temporary lines I came up with (until the occasion presents itself with the client the problem occurs).


loop:
sleep 500
IFFileExists "C:\install\file.rar" +2 +1
goto loop
nsExec::ExecToLog ...etc...

Much cleaner:

${For} $R0 1 20
${If} ${FileExists} `C:\install\file.rar`
${Break}
${EndIf}
Sleep 1000
${Next}
${Unless} ${FileExists} `C:\install\file.rar`
MessageBox MB_OK `Error!`
Abort
${EndUnless}

It may take more lines of code, but at the end of the day, we read old code more than we write code.

Stu