Followers 0

# Deleting temp files placed via FileInstall

## 2 posts in this topic

#1 ·  Posted

I have a script that I wanted to play a "goodbye" sound when exiting. I used FileInstall to copy the wav file to @TempDir. Being the neat freak that I am I want to delete the file after it is played. I used FileDelete at the end of my script to delete it but the file will not delete. Apparently, the script keeps the file in use so it cannot be deleted.

What is the proper way to use a file as a temporary file and delete it when done?

Thanks,

Derek

##### Share on other sites

#2 ·  Posted

Why don't you try including a function that deletes the file when the script closes.  Try this:

OnAutoItExitRegister ( "deletefile" )

;code goes here

Func deletefile ()
Run ( @ComSpec & ' /c timeout 4 & del "PAth\to\file.wav"' )
Exit
EndFunc