Jump to content
Sign in to follow this  
AetherMaster

Creating a "Temporary" executable

Recommended Posts

AetherMaster

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.

Share this post


Link to post
Share on other sites
Tvern

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.

Share this post


Link to post
Share on other sites
AetherMaster

Much appreciated. Thanks.

Share this post


Link to post
Share on other sites
Spiff59

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

Share this post


Link to post
Share on other sites
Juvigy

Put

_SelfDelete()
in the end of your script.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.