Art Posted March 12, 2009 Share Posted March 12, 2009 I'd like to have a script delete its image on disk. For example, if I have a script, abc.exe (loaded in memory and running), can I somehow add code and compile to delete the file abc.exe on disk when abc.exe is running. This is for the purpose of cleaning up the disk so that there's no trace of abc.exe after the first execution. Thanks, Art Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 12, 2009 Share Posted March 12, 2009 As posted in the FAQ. 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 Link to comment Share on other sites More sharing options...
dantay9 Posted March 12, 2009 Share Posted March 12, 2009 in case you didn't know, you can also just type selfdelete and it will automatically write the function for you. Link to comment Share on other sites More sharing options...
Achilles Posted March 12, 2009 Share Posted March 12, 2009 in case you didn't know, you can also just type selfdelete and it will automatically write the function for you.Where is this? Like, where do actually type "selfdelete"? My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
Richard Robertson Posted March 12, 2009 Share Posted March 12, 2009 Are you talking about using SciTE and the list of substitutions? That is an editor specific feature. Link to comment Share on other sites More sharing options...
jvanegmond Posted March 13, 2009 Share Posted March 13, 2009 Where is this? Like, where do actually type "selfdelete"?Yeah, in SciTe4AutoIt3 you type:selfdeleteshift + spacebar github.com/jvanegmond Link to comment Share on other sites More sharing options...
BinaryBrother Posted March 13, 2009 Share Posted March 13, 2009 (edited) WOW... I'm been coding in AutoIt for 3 years.. and Didn't know that... That is a handy trick! Edited March 13, 2009 by BinaryBrother SIGNATURE_0X800007D NOT FOUND Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now