Archive: Delete external files


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"


Try:

Delete "$INSTDIR\filename"

the files are copied to a "self chosen" directory. so maybe the files are not in $INSTDIR.


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.


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.

??


Then you're probably experiencing the problem described in the following FAQ item:
http://nsis.sourceforge.net/index.ph...&tx_faq_faq=20


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.


When you say the file exists, did you do it with IfFileExists?

IfFileExists "filepath" 0 +2
MessageBox MB_OK "filepath exists!"

-Stu


I'll check that tomorrow! If I remember I did not check with IfFileExist.


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.

*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)