geoffrey_4js
8th June 2005 16:21 UTC
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
Brummelchen
8th June 2005 16:34 UTC
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"
RobGrant
9th June 2005 08:56 UTC
I didn't think that the OutPath had anything to do with deleting...
geoffrey_4js
9th June 2005 09:24 UTC
So do you know why 'Delete "$OUTDIR\flmprg.exe"' in the uninstall section doesn't work all the time ?
RobGrant
9th June 2005 14:18 UTC
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!"
geoffrey_4js
10th June 2005 08:13 UTC
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
Afrow UK
10th June 2005 14:37 UTC
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
geoffrey_4js
10th June 2005 14:57 UTC
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!"
Afrow UK
10th June 2005 15:39 UTC
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
geoffrey_4js
10th June 2005 15:53 UTC
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