- NSIS Discussion
- Delete external files
Archive: Delete external files
blue_raptor
11th May 2005 11:03 UTC
Delete external files
In my installation script I copy two self chosen files to a self chosen directory. These files are NOT compiled within the installer.
Is it possible to delete them with the uninstaller? I retrieve error when trying that with: Delete "filename"
kichik
11th May 2005 14:10 UTC
Try:
Delete "$INSTDIR\filename"
blue_raptor
11th May 2005 14:45 UTC
the files are copied to a "self chosen" directory. so maybe the files are not in $INSTDIR.
kichik
11th May 2005 14:52 UTC
In the uninstaller, $INSTDIR is the directory where the uninstaller resides. If the uninstaller is not written to the same directory as those files, you'd have to find the path of those files first and pass it on to Delete.
blue_raptor
11th May 2005 16:16 UTC
hm sorry. in my first post i wrote Delete "filename" but filename contains also the complete path.
like: c:\temp\example.txt
I read this out from an config file of the application. I succesfully checked the filename with a MessageBox. The file exists but I can not delete it.
??
kichik
11th May 2005 16:22 UTC
Then you're probably experiencing the problem described in the following FAQ item:
http://nsis.sourceforge.net/index.ph...&tx_faq_faq=20
blue_raptor
11th May 2005 20:06 UTC
hm. I found that faq, too and tried it. but it does not work. maybe i did something wrong. tomorrow i can post the code (it's at work).
or it's the filename... at the installation process i have to escape "\" and " ", because the installed programm (openVPN) need it in the config file. on deinstallation i have to "re"escape the string (from "\\" to "\" and "\ " to " "). maybe there went something wrong.
Afrow UK
11th May 2005 20:10 UTC
When you say the file exists, did you do it with IfFileExists?
IfFileExists "filepath" 0 +2
MessageBox MB_OK "filepath exists!"
-Stu
blue_raptor
11th May 2005 20:46 UTC
I'll check that tomorrow! If I remember I did not check with IfFileExist.
blue_raptor
12th May 2005 06:51 UTC
I checked it with IfFileExists (see code)
delete:
${
UnStrRep} $tmp $tmp "\\" "\"
${UnStrRep} $tmp $tmp " " " "
${UnStrTrimNewLines} $tmp $tmp
DetailPrint "Lösche Datei $tmp"
IfFileExists $tmp FileExists FileNotExists
FileExists:
MessageBox MB_OK "Die Datei $tmp existiert"
goto loop
FileNotExists:
MessageBox MB_OK "Die Datei $tmp existiert nicht"
goto error
>
The installer goes to the FileNotExists: label. I don't know why. The content of $tmp 'seemed' to be correct (for me, but apparent not for the uninstaller.
blue_raptor
12th May 2005 07:02 UTC
*oh oh* I feel so ashamed. Sorry guys for waisting your time!
I did a "noob" mistake in programming. I cut the filepath with StrCpy $tmp $2 "" 4
but it has to be
StrCpy $tmp $2 "" 5
:igor:
For this weekend I'll creep away.
edit: my installer und uninstaller works fine for now (in that way it should work)