AetherMaster Posted July 15, 2010 Share Posted July 15, 2010 I know the topic title may sound confusing, but it makes sense if I explain how my script works. The script is extracted from a WinRAR Self-Extracting archive so that it can be run from any computer. When the script exits, I want the program to delete all files that were extracted. This isn't possible though, since the program that's running can't delete itself. I got around this by leaving a temporary "cleanup" program on the computer which runs when the main script closes. It works for deleting the files, but it gets left behind undeleted. So here's my question to you - is it possible to make a temporary executable that will delete itself when it closes? This way, my script won't leave anything behind on the computer from which it's run. Link to comment Share on other sites More sharing options...
Tvern Posted July 15, 2010 Share Posted July 15, 2010 Here is an example: http://www.autoitscript.com/wiki/FAQ#How_can_I_have_the_script_delete_itself.3F It creates a batch file that will delete the script and then deletes itsself. Link to comment Share on other sites More sharing options...
AetherMaster Posted July 15, 2010 Author Share Posted July 15, 2010 Much appreciated. Thanks. Link to comment Share on other sites More sharing options...
Spiff59 Posted July 16, 2010 Share Posted July 16, 2010 (edited) Here is an example: http://www.autoitscript.com/wiki/FAQ#How_can_I_have_the_script_delete_itself.3FIt creates a batch file that will delete the script and then deletes itsself.Does that actually work?I haven't tried it, but just glancing at it, it appears there are at least four places where invalid pathnames are constructed (missing '\').Edit: I s'pose it ought to still work, it just creates a file named "tempscratch.bat" in the wrong directory. If anyone corrects it, I think the description "The following code can delete a running script." could use some elaboration, since you can't delete something that's running.Edit2: Nevermind, I created a wiki account and fixed it myself. Edited July 16, 2010 by Spiff59 Link to comment Share on other sites More sharing options...
Juvigy Posted July 16, 2010 Share Posted July 16, 2010 Put _SelfDelete() in the end of your script. 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