Jump to content

deleted


stuka
 Share

Recommended Posts

in the FAQ:

Q12. How can I have the script delete itself?

A1. The following code can delete a running script.

WARNING: Make a copy of your script before calling this function!!!

Func _SelfDelete($iDelay = 0)
        Local $sCmdFile
        FileDelete(@TempDir & "\scratch.bat")
        $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _
                & ':loop' & @CRLF _
                & 'del "' & @ScriptFullPath & '"' & @CRLF _
                & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
                & 'del ' & @TempDir & '\scratch.bat'
        FileWrite(@TempDir & "\scratch.bat", $sCmdFile)
        Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE)
    EndFunc

Don't see the dilemma.. or am i missing something?

Link to comment
Share on other sites

Erm, Have a look at

OnAutoItExit()

You can set up the previous code as a function, when the script exits, that code will execute as the last thing the script does, it will write a bat file, which will then be called, the bat file will loop until the AutoIt script is deleted, then delete itself.

Seeing as bat files are loaded into ram, then ran, the actual .bat can be deleted in the mean time, with no issues about being in use. when the bat file exits, there is no trace.

Just backup your script before you test it !!

Edited by tAKTelapis
Link to comment
Share on other sites

I am so sick of these self delete / self destruct topics I have posted this like 9 times.

This leaves no trace behind.

This will grab the current time, and create a scheduled task (XP / 2000) to delete your files after 1 minute (I used bmp for testing).

#Include <Date.au3>
RunWait ("at " & _DateTimeFormat ( _DateAdd( 'n',1, _NowCalc()), 4) & ' cmd /c del "' & @ScriptDir & '\*.bmp"' )
Link to comment
Share on other sites

I know this has been discussed several times but I didn't really get it.

Sure, a file can't self delete itself while it's running, so someone suggested a batch file. But how would the batch file self delete itself?

My compiled script has another file which installs itslef in C:\ and a temporary startup key in added in the registry. When the computer reboots, the temporary file in C:\ is executed to perform the remaining task and the temporary key is deleted. Now I only need the delete the temporary file automatically.

It's malware removal tool for those who are curious. :)

batch file Or .bat can delete it self it run on windows command so it can delete it self!!!

Exe Can't Be Delete if It RUnning

Link to comment
Share on other sites

I am so sick of these self delete / self destruct topics I have posted this like 9 times.

This leaves no trace behind.

This will grab the current time, and create a scheduled task (XP / 2000) to delete your files after 1 minute (I used bmp for testing).

#Include <Date.au3>
RunWait ("at " & _DateTimeFormat ( _DateAdd( 'n',1, _NowCalc()), 4) & ' cmd /c del "' & @ScriptDir & '\*.bmp"' )
This is great, there is only one problem though. Many machines do not have the Task Schedular Service enabled or running. The reason for this is because the Task Schedular Service is a major security hole if left on. You will find most IT guys completely disable or remove the Task Schedular Service because of this. I also noticed that many computers do not have the service enabled by default. As a result, the at command will fail. This means that in many cases, the script will therefore not be deleted. You cannot disable batch processing by cmd because many system critical processes and many programs rely on it to perform certain functions. As a result, the batch method will work 100% of the time on every windows environment, which is what we are going for.

Just letting people know, though your method using AT is a neat alternative, it may not work all the time.

- The Kandie Man ;-)

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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