Jump to content

Recommended Posts

Posted

Hi Guys,

I've been fighting with this issue in the last hour.

I'm trying to delete my compiled script when exiting the script. I'm using @AutoitExe to get the script name that needs to be delete but FileDelete is not deleting this file.

My code is below

Opt("OnExitFunc","_Cleanup")

$file = FileOpen("test.txt", 0)

$output="log.txt"

$handle = FileOpen($output,1)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

; Read in lines of text until the EOF is reached

While 1

$line = FileReadLine($file)

If @error = -1 Then ExitLoop

FileWriteLine($output, "Line read:" & $line)

Wend

FileClose($file)

FileClose($handle)

Func _Cleanup()

FileDelete(@AutoitExe)

EndFunc

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...