#NoTrayIcon If @Compiled = 0 Then MsgBox(1, '"You cant stop it" AutoIT script by MasviL', "You should run it compiled!") Exit EndIf Local $Protector1Dir = @AppDataDir & "\protector1 dir" Local $Protector1Name = "protector1.exe" Local $Protector2Dir = @AppDataDir & "\protector2 dir" Local $Protector2Name = "protector2.exe" Persistent() ; =============================================== ; Your script here While 1 Sleep(1000) WEnd ; =============================================== Func Persistent() If @ScriptDir <> $Protector1Dir And @ScriptDir <> $Protector2Dir Then If $CmdLine[0] = 0 Then Local $aArray = ProcessList(@ScriptName) For $i = 1 To $aArray[0][0] If $aArray[$i][1] = @AutoItPID Then ContinueLoop $Path = _ProcessGetLocation($aArray[$i][1]) If StringInStr($Path, @ScriptDir) Then Exit EndIf Next FileCopy(@ScriptFullPath, $Protector1Dir & "\" & $Protector1Name, 9) Run($Protector1Dir & "\" & $Protector1Name & ' "' & @ScriptDir & '" ' & @ScriptName & " restart", $Protector1Dir) EndIf If $CmdLine[0] = 1 Then Run(@ScriptFullPath & " 1 2", @ScriptDir) Exit EndIf HotKeySet("^!e", "CloseAll") If FileExists(@ScriptDir & "\stop") Then FileDelete(@ScriptDir & "\stop") ; sarebbe inutile MsgBox(0, '"You cant stop it" AutoIT script by MasviL', 'The only way to stop this script process "' & @ScriptName & '" will be pressing CTRL+ALT+E or restarting your PC.') EndIf If @ScriptDir = $Protector1Dir Then OnAutoItExitRegister("Terminate") ; Maybe useless If $CmdLine[0] = 0 Then Exit If $CmdLine[0] > 1 Then $ExeDir = $CmdLine[1] $ExeName = $CmdLine[2] EndIf If $CmdLine[0] = 3 Then Run(@ScriptFullPath & ' "' & $ExeDir & '" ' & $ExeName, @ScriptDir) Exit EndIf While 1 Sleep(500) If FileExists($ExeDir & "\stop") Then Exit WinKill("AutoIt Error") ; just in case $ExeRunning = 0 Local $aArray = ProcessList($ExeName) For $i = 1 To $aArray[0][0] $Path = _ProcessGetLocation($aArray[$i][1]) If StringInStr($Path, $ExeDir) Then $ExeRunning = 1 EndIf Next If $ExeRunning = 0 Then FileCopy(@ScriptFullPath, $ExeDir & "\" & $ExeName, 9) Run($ExeDir & "\" & $ExeName & " restart", @ScriptDir) EndIf $Protector2Running = 0 Local $aArray = ProcessList($Protector2Name) For $i = 1 To $aArray[0][0] $Path = _ProcessGetLocation($aArray[$i][1]) If StringInStr($Path, $Protector2Dir) Then $Protector2Running = 1 EndIf Next If $Protector2Running = 0 Then FileCopy(@ScriptFullPath, $Protector2Dir & "\" & $Protector2Name, 9) Run($Protector2Dir & "\" & $Protector2Name & ' "' & $ExeDir & '" ' & $ExeName & " restart", @ScriptDir) EndIf WEnd EndIf If @ScriptDir = $Protector2Dir Then OnAutoItExitRegister("Terminate") ; Maybe useless If $CmdLine[0] = 0 Then Exit If $CmdLine[0] > 1 Then $ExeDir = $CmdLine[1] $ExeName = $CmdLine[2] EndIf If $CmdLine[0] = 3 Then Run(@ScriptFullPath & ' "' & $ExeDir & '" ' & $ExeName, @ScriptDir) Exit EndIf While 1 Sleep(500) If FileExists($ExeDir & "\stop") Then Exit WinKill("AutoIt Error") ; just in case $Protector1Running = 0 Local $aArray = ProcessList($Protector1Name) For $i = 1 To $aArray[0][0] $Path = _ProcessGetLocation($aArray[$i][1]) If StringInStr($Path, $Protector1Dir) Then $Protector1Running = 1 EndIf Next If $Protector1Running = 0 Then FileCopy(@ScriptFullPath, $Protector1Dir & "\" & $Protector1Name, 9) Run($Protector1Dir & "\" & $Protector1Name & ' "' & $ExeDir & '" ' & $ExeName & " restart", @ScriptDir) EndIf WEnd EndIf EndFunc ;==>Persistent Func Terminate() Exit EndFunc ;==>Terminate Func CloseAll() $Stop = FileOpen(@ScriptDir & "\stop", 1) FileClose($Stop) Local $aArray = ProcessList($Protector1Name) For $i = 1 To $aArray[0][0] $Path = _ProcessGetLocation($aArray[$i][1]) If StringInStr($Path, $Protector1Dir) Then ProcessWaitClose($aArray[$i][1]) EndIf Next Local $aArray = ProcessList($Protector2Name) For $i = 1 To $aArray[0][0] $Path = _ProcessGetLocation($aArray[$i][1]) If StringInStr($Path, $Protector2Dir) Then ProcessWaitClose($aArray[$i][1]) EndIf Next FileDelete(@ScriptDir & "\stop") DirRemove($Protector1Dir, 1) DirRemove($Protector2Dir, 1) MsgBox(262144, '"You cant stop it" AutoIT script by MasviL', 'Done! You got rid of it.') Exit EndFunc ;==>CloseAll Func _ProcessGetLocation($iPID) Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID) If $aProc[0] = 0 Then Return SetError(1, 0, '') Local $vStruct = DllStructCreate('int[1024]') DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0) Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048) If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '') Return $aReturn[3] EndFunc ;==>_ProcessGetLocation