Archive: NSIS delete function seems to lock files


NSIS delete function seems to lock files
Hi All,

I'm using NSIS to deliver updates for the product I work on. Just recently I needed to delete a file on the destination machine prior to copying/extracting it from the installer. Although the delete process and copy process seemed to have worked correctly there were issues when it came to using the file later in the installation script.

These are the basic steps(sections) performed:
1. Delete fileX from destination machine
2. Install/extract fileX onto destination machine
3. Execute a function that uses and modifies fileX

* If I run with all 3 steps the 3rd step fails.
* If I manually delete the file and only run steps 2 and 3 the installation works.
* If I put a sleep in between step 1 and 2 the installation works.

I would like to find a better solution to putting a sleep after the delete, also I'm wondering what is actually occuring.

If the NSIS installer is locking the file can it be unlocked?
Has anyone seen something similar to the above scenario?


The reason that sleep solves the problem is that the destination machine did not finish step 1/2 when you start step 3. You should give it some time to finish the task. Eg. with a sleep.

-Hendri.


What NSIS version are you using?
What Windows version are you using?
Have you set the overwrite flag to anything else than the default?


Running
* NSIS v2.0a7 modern interface.
* Win2k Pro
Overwrite flag set to ifnewer


I am having problems with Delete, too.

If this conforts you:confused:


Why don't you just overwrite the file?