I have created an exit function and registered using OnAutoItExitRegister.But it is not running when I close the app from taskbar or even with normal exit during end.
Below is the part of code and the included files.
#include <MsgBoxConstants.au3>
#include <FileConstants.au3>
#include <WinAPIFiles.au3>
#include <Date.au3>
#include <file.au3>
#include <Array.au3>
#include <String.au3>
OnAutoItExitRegister("Exit_Program")
Func Exit_Program()
LoggingMainScr("Entered Exit_Program")
Local $exitmethod = ["Natural closing", "close by Exit function", "close by clicking on exit of the systray","close by user logoff","close by Windows shutdown"]
ExitProgram("Exit with exit code: "& @exitCode & " And because of: " & $exitmethod[@exitmethod],@exitmethod)
EndFunc
Func ExitProgram($sReason="Exit by user",$sCode=0)
LoggingMainScr($sReason)
if $sCode <> 0 then LoggingMainScr("stopped before completion")
FileDelete(@ScriptDir&"\Machines*.txt")
FileDelete(@ScriptDir&"\PsExec.exe")
FileDelete(@ScriptDir&"\HyperVMachines.ps1")
FileDelete(@ScriptDir&"\VMwareMachines.ps1")
EndFunc
Func LoggingMainScr($sMessage)
LoggingDefault($sMessage,@ScriptDir&"\MainScr_Logging.log")
EndFunc
Func LoggingDefault($sMessage,$sLogFile=@ScriptDir&"\Logging.log")
If $sMessage = "" Then
FileWriteLine($sLogFile, "")
Else
FileWrite($sLogFile,_NowCalc() & " :: " & $sMessage&@CRLF)
EndIf
EndFunc
Any suggestion.