Archive: Problem to delete a file


Problem to delete a file
Hello,

With NSIS 2.06.

In the uninstall section, i wanted to delete a specific file.

If I do the following, it works :

  
SetOutPath "$INSTDIR"
MessageBox MB_OK "Before deleting the file"
Delete "$OUTDIR\bin\flmprg.exe"


I don't want to display a message box but the following doesn't work (it doesn't delete the file:


SetOutPath "$INSTDIR"
Delete "$OUTDIR\bin\flmprg.exe"


So i'm doing the following trick but the progress bar during uninstall is "jumping"


SetOutPath "$INSTDIR"
${UnFileOrDirStatus} $R1 "$OUTDIR\bin\flmprg.exe"
${While} $R1 != "does not exist"
Delete "$OUTDIR\bin\flmprg.exe"
${UnFileOrDirStatus} $R1 "$OUTDIR\bin\flmprg.exe"
${EndWhile}


Is this a bug or am i doing something wrong ?

EDIT : seems that a sleep help a little bit :
SetOutPath "$INSTDIR"
${UnFileOrDirStatus} $R1 "$OUTDIR\bin\flmprg.exe"
${While} $R1 != "does not exist"
sleep 200
Delete "$OUTDIR\bin\flmprg.exe"
${UnFileOrDirStatus} $R1 "$OUTDIR\bin\flmprg.exe"
${EndWhile}


Geoffrey

SetOutPath "$INSTDIR"
Delete "$OUTDIR\bin\flmprg.exe"
what about
SetOutPath "$INSTDIR"
Delete "$INSTDIR\bin\flmprg.exe"
???

>> The current output directory

It may easier with
SetOutPath "$INSTDIR\bin"
Delete "$OUTDIR\flmprg.exe"

I didn't think that the OutPath had anything to do with deleting...


So do you know why 'Delete "$OUTDIR\flmprg.exe"' in the uninstall section doesn't work all the time ?


Is the file in use? Does this bring up a popup box:


ClearErrors
Delete "$OUTDIR\flmprg.exe"
IfErrors 0 +2
MessageBox MB_OK "Oops, I got an error!"

I get an error, the .exe is used to start a service but the service is stopped before trying to delete the file (i've check in the Services Windows Admin Tools).

I'll keep my "While Loop" solution.

Thx


This:
SetOutPath "$INSTDIR"
MessageBox MB_OK "Before deleting the file"
Delete "$OUTDIR\bin\flmprg.exe"
Is the same as using this:
MessageBox MB_OK "Before deleting the file"
Delete "$INSTDIR\bin\flmprg.exe"

Try this:
ClearErrors
Delete "$INSTDIR\bin\flmprg.exe"
IfErrors 0 +2
MessageBox MB_OK "ERROR!"

-Stu


Still the same problem

I get the "ERROR!" message box


ClearErrors
Delete "$INSTDIR\bin\flmprg.exe"
IfErrors 0 +2
MessageBox MB_OK "ERROR!"


I don't get the "ERROR!" message box

ClearErrors
MessageBox MB_OK "Before deleting the file"
Delete "$INSTDIR\bin\flmprg.exe"
IfErrors 0 +2
MessageBox MB_OK "ERROR!"

Try replacing the MessageBox MB_OK "Before deleting the file" with Sleep 2000

I'm guessing you aren't giving it enough time to close before deleting it (and the MessageBox is)

-Stu


You are right Afrow UK, it was windows that's taking time.

With a sleep 1000 instead of the message box i escape the ERROR! message.

Thx