View Full Version : How to handle cancel when using XCopyFile to install files???

02-01-2005, 01:27 PM
Our installation requires the user to be able to install the same feature multiple times, which InstallShield does not support. Because of this, we are converting our project to manually copy all installation files via the XCopyFile and StatusUpdate functions.

The problem I'm having, is figuring out how to cleanup files when the user presses the 'Cancel' button during the install, because InstallShield leaves all the files it already copied on the users system, instead of automatically cleaning them up like it does on an uninstall.

It appears that XCopyFile returns an error code of -2147213311 when the user presses 'Cancel', so at first I thought I'd catch this and just delete all files that I tried copying over. The problem is that I do a copy using the *.* wildcard, and I don't want to delete *.* because users may have other files in that destination directory, and I don't want to delete everything. Since there could be thousands of files I'm copying over, it would be too hard to try and delete each one manually. Or if some files already exists, I wouldn't want to delete those files that previously existed, just the new files copied over.

Any ideas?

02-01-2005, 05:28 PM
Ah, this problem was fixed when I fixed a related issue.

Basically, when the user hits "cancel" during the file transfer, I was just aborting my functions which did no cleanup work. Instead, I needed to call 'Do(EXIT);' which properly aborts the setup AND cleans files copied during the setup.