- NSIS Discussion
- SelfDel plug-in
Archive: SelfDel plug-in
Takhir
21st January 2006 13:31 UTC
SelfDel plug-in
In the kichik' post (multi-volume discussion thread) I found link to another thread and finally link to article with self deletion techniques description. It was very interesting for me, because very long ago I wrote my own installers and tested most of variants described in the article, but not the last one :) So first I wrote application with additional RMDir (original code included variables for this, but not the code), and then converted it to NSIS plug-in.
Put dll to your NSIS plug-ins dir. Build included sample and run it. Installer creates uninstaller in the 'unsd' subfolder and link in the current folder to uninstaller with _? parameter. A bit strange, but 'unsd' folder appeares after F5 only, may be because of repeating names in folder, so press F5. Run 'unsd' link, after this link should dissappear, Close uninstaller when it finishes. After this (process exited) still remaining in memory plug-in's code removes uninstaller and folder. On my home XP this works :)
http://nsis.sourceforge.net/SelfDel_plug-in
Instructor
22nd January 2006 23:31 UTC
Great! One thing: could plug-in calls from on.unGUIInit function? In section cursor looks perplexed, when plugin wait for exit.
Takhir
23rd January 2006 07:20 UTC
Thanks, Instructor, now looks better in the un.onGUIEnd :)
Finally this is more concept, then plug-in, but may be useful for huge uninstallers right now. I also tested plug-in in office on 98SE/XP/2000/2003. On 2003 this worked with little delay (2 sec), but result was correct. And hidden Explorer process (56 kB) exits after folder deletion on all systems. Code author declared Win95 compatibility, but I could not find virgin 95 for test.
fishsauce
9th February 2008 05:31 UTC
Explorer dies on Vista with this plugin... any other ways for an installer to self destruct?
Afrow UK
9th February 2008 15:55 UTC
Write another executable which when ran waits 2 seconds and then deletes your installer. So, extract it from your main install, and run it on exit. To ensure that that executable is deleted as well, do a Delete /rebootok after executing it so that it is deleted on reboot. You'd need to pass the original executable's path to the secondary one either via the command line or via the registry.
Stu
fishsauce
11th February 2008 22:57 UTC
Okay, I'll try doing that. I was hoping there's some kind of compiler flag that we can just put on our installer to take advantage of whatever mechanism the NSIS-generated uninstallers use right now to delete themselves.
Afrow UK
11th February 2008 23:21 UTC
The uninstallers work in the same way I would think. They copy themselves to the temp folder and run from there instead then that copy is possibly deleted on reboot or maybe then as you say.
Stu
Afrow UK
17th July 2011 22:31 UTC
I have fixed this plug-in to work on x64 and added a Unicode build.
Edit: Now self-deletes on reboot on failure if possible.
Stu
Afrow UK
10th August 2011 12:08 UTC
Realised the plug-in wasn't working on XP or lower any more. Fixed that and added a /REBOOT switch which will reboot the machine after the installer has been deleted. It can be used in conjunction with /RMDIR.
http://nsis.sourceforge.net/SelfDel_plug-in
Stu
Afrow UK
17th September 2012 19:02 UTC
New version. Fixes self-deletion on Windows 7/8 32-bit.
http://nsis.sourceforge.net/SelfDel_plug-in
Stu