On the other hand, various programs' uninstall scripts successfully delete the entire directory tree, including the uninstaller. Don't know how they do it.
The uninstaller is an msiexec.exe script. The (un)installer in an integral part of the os. So the problem doesn't happen. In the old days, InstallShield offered a ugly trick to do what Norbert wants. Simply use luatex to write a .bat file doing a loop to remove your luatex.exe and itself. Launch the bat file from luatex (cmd /c foo.bat) and quit luatex. Ok, it is ugly. You also have the option to set the file to be removed after the next reboot (dlls, com components and so). And let the user reboot to finish the cleanup. You won't escape the fact that under Windows, any file that for which an open handle exists can't be deleted. Installation is a native service under Windows. You may want to play your own game, but expect annoyances. Regards, Fabrice