Archive: Delete Problems. Maybe I'm Just stupid (Hope not...)


Delete Problems. Maybe I'm Just stupid (Hope not...) Please Help!
Yes : I searched the forum for this topic, but didn't find anything that fit my problem.

Ok. Ive been using NSIS for some time, but I've never tried to delete files specified by a variable...
This is what I do in my uninstaller :

Delete $2
;where $2 is a filename like C:\crap\myfile.bla

;I also tried to do :
Delete "$2"

;and to envelop the filename in ""'s like :
;$2 = "C:\crap\myfile.bla"

but still the file doesn't get deleted...
The files are not beeing used/open/whatever in any way!!!
They're not hidden/system files...
When I specify files directly, or using "$INSTDIR\myfile.bla" it works just fine...

Im used NSIS version 1.98 and then downloaded the new version v2.0b0
which does the same thing.
I'm using the old GUI and Windows2000

Help would be greatly appreciated!

KIM


StrCpy $2 "c:\foo"


It is rather big!!!

I can tell you that the variable contains the right file name, as i made some debug output!

I'll state the sections that have to do with deleting the file :

Function un.delete_file
push $R0
StrCpy $R0 $2 3 -3 ;get file extension
StrCmp $R0 "dll" unreg delfile
StrCmp $R0 "ocx" unreg delfile
unreg:
UnRegDLL $2
delfile:
Delete "/REBOOTOK" $2
pop $R0
FunctionEnd

The variable $2 is read from a logfile i create myself, and I am sure the filename is right!!!
I also tried :
Delete $2
Delete "$2"
and to add " to the filename at the front + back...


Sorry, you edited your post while I was typing ;-)

What do you mean with
StrCpy $2 "C:\foo"


I think the file reading goes wrong. Use StrCpy and check wheather it works.


Thank you, the problem was that I read the "lines" from a file and the $\r$\n didn't get cut correctly, so the files didn't get deleted... Now it works.
The filenames seemed to be correct, and I didn't notice that the CRLF shouldn't be there.

Sorry for bothering...

KIM


Unrelated, but just spotted a bug in your function (might have just been a typo when you wrote the message):


...
StrCmp $R0 "dll" unreg delfile
StrCmp $R0 "ocx" unreg delfile
...

The second StrCmp will never be executed because the first one branches off somewhere else in all cases.

HTH!

Dave.