Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To have a program literally delete itself without any trace you need to ask at least <em>someone else</em> to delete your (last) executable after it has shut down. This is because a running executable will be in use, and you'd get a sharing violation if you delete it from the code that is running.</p> <p>You could use Windows for this, I think, using a registry setting of commandlines to run when Windows starts. You could put `delete [full path to your executable]' there. (Google for the correct registry setting if you really need this.)</p> <p>Another good option seems to be the first link in the reply by <code>Aamir</code>: just before exiting your executable you start another process that uses parts of Windows to wait a bit and then delete your executable.</p> <p>Yet another option is to make sure you have a correct installer package (e.g. an MSI package) that does what you want using the installer subsystem (e.g. MS Installer) of the OS you're on (e.g. Windows). But this only works if your application has/needs a full installer at all.</p> <p>It would work like this: when the user uninstalls, let your installer packages make sure the application executable is not currently running. It can show the user that it is and ask to close application before continuing, or it can terminate its process after a confirmation. After this it can delete all files that were installed by the package, including the executable.</p> <p>In VB.NET/C# in VisualStudio you can use a Custom Installer class to add the "make sure my executable is not running" logic. Or use a third party installer tool to create the installer package that can do this for you automatically.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload