#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include #include while 1 Local $iID = ProcessExists('img001.exe') If $iID Then $fileLoc = _WinAPI_GetProcessFileName($iID) LoggingDefault($fileLoc) Local $pc = ProcessClose($iID) If $pc Then LoggingDefault("The process closed successfully.") Else LoggingDefault("An error occurred whilst killing the process.") EndIf If FileExists($fileLoc) then Sleep(2000) LoggingDefault("File exists and trying to delete") Local $iDelete = FileDelete($fileLoc) If $iDelete Then LoggingDefault("The file was successfuly deleted.") Else LoggingDefault("An error occurred whilst deleting the file.") EndIf Else LoggingDefault("File Not found: "&$fileLoc) EndIf EndIf WEnd Func LoggingDefault($sMessage,$sLogFile=@ScriptDir&"\Logging.log") If $sMessage = "" Then FileWriteLine($sLogFile, "") Else FileWrite($sLogFile,_NowCalc() & " :: " & $sMessage&@CRLF) EndIf EndFunc