Archive: SelfDel plug-in


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


Great! One thing: could plug-in calls from on.unGUIInit function? In section cursor looks perplexed, when plugin wait for exit.


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.


Explorer dies on Vista with this plugin... any other ways for an installer to self destruct?


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


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.


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


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


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


New version. Fixes self-deletion on Windows 7/8 32-bit.

http://nsis.sourceforge.net/SelfDel_plug-in

Stu