Page 1 of 1

How to delete a file ????

Posted: Tue Mar 21, 2006 10:43 am
by MikeFieger
Hi

I know this really sounds like a stupid question, but I really can not delete a file upon uninstalling my program.

I am using the command 'Delete Files $TARGETDIR$\\Test.tmp (when uninstalling)' but it just doesn´t work...

I tried it before and after 'Apply Uninstall'

I wrote the filename to the screen using a messagebox to check if the path is right -> it is.

I tried it with a manually created textfile C:\\Test.txt...

The file is not write protectet or in use by any other program....

What else can there be wrong? Please help a desperate customer :x

Posted: Tue Mar 21, 2006 3:01 pm
by jimo
Mike,
I find it best to use the Call DLL script action and call "DeleteFileA" in kernel32.dll like

Code: Select all

~InstallAware Clipboard Data~
~Call DLL Function~
~{AC025F56-F43C-4F07-A566-B815B48F6AE4}~
~kernel32.dll,DeleteFileA,bool,LASTERROR,"pointer to string",$APPDIR$\\WebUpdate\\MDPM_WebUpdate.exe,$~
~mIDEFunc.dll\\mEXEFunc.dll~

Which is :
Call DLL Function kernel32.dll->DeleteFileA (get result into variable LASTERROR)

Paste the code block above into your script and edit the value of the string to the appropriate value.

Posted: Tue Mar 21, 2006 3:23 pm
by MichaelNesmith
That's a great suggestion from Jim, thank you.

If you are also wondering why the native Delete File command did not work, this is slightly tricky so we have a FAQ about it in the help files -

"Setup Commands Preceding Apply Uninstall"

should answer your question (look it up in the help index or under the Getting Results book).

Posted: Wed Mar 22, 2006 3:24 am
by MikeFieger
Thank you for your answers!

Moving the delete command from the uninstall- to the install-section solved the problem.
:)