Archived Forum Post

Index of archived forum posts


How to Automatically Clean Up Files from Temp Directory after Self-Extract?

Nov 14 '12 at 19:16

Converting some of our code to use your zip component. Is there any way to have the self-extracting executable clean up the AutoTemp directory when the AutoRun exe exits?

Ideally, when our program finishes, the temp directory and all files created in it by the self-extractor would be deleted.


(The Chilkat Self-Extracting EXE functionality in the Chilkat Zip class/component only applies to Windows systems.)

The AutoTemp property, if set to true, tells the self-extractor to automatically choose a temp directory for extraction. It only makes sense to use AutoTemp with AutoRun, which tells the self-extractor which EXE after extraction is to be run as the "setup program". (Otherwise, what would be the point of simply extracting files in some unknown temp directory and leaving them there?)

OK.. now to answer the question.

At a certain point in the history of Chilkat Zip, more and more self-extracting properties were needing to be added, and it became apparent that adding individual properties was not a good way to go. The zip.ExeXmlConfig property is an XML string that contains all of the self-extracting EXE related properties. For example, if you set the AutoTemp property = true, you'll find that an "AutoRun" XML node gets added to the ExeXmlConfig property. There are many features that can be specified via the ExeXmlConfig but don't have a getter/setter property in the API. The "Cleanup" property is an example.

Your program can indicate that it wants auto-cleanup of temp files by adding a "<Cleanup>1</Cleanup>" node to the ExeXmlConfig.

Unfortunately, there are still some features that are not yet documented...