Jump to content

Creating a "Temporary" executable


Recommended Posts

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

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.

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 by Spiff59
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...