Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Problem deleting exe (http://forums.winamp.com/showthread.php?t=452014)

pkonduru 2nd November 2017 20:41

Problem deleting exe
 
Hi Folks,

So I have an NSIS installer(no uninstall section), I should probably call it an uninstaller as all it does is delete files and removes some registry entries. I am basically using NSIS to delete a product that is installed in some other technology. Everything works fine but I am not able to delete the exe itself that am running. My installer gets called from the registry key, HKLM\Microsoft\windows\CurrentVersion\Uninstall\[Some_Dir]\uninstall.exe

Is there any switch I can add in the registry string, something similar to ExecWait to delete the exe itself after it has run?

Nutzzz 2nd November 2017 23:23

3 options I can think of:
1. You could be content with the /REBOOTOK switch for Delete and RMDir, and let Windows automatically delete the file and folder after the next reboot.
2. You could change your logic to make an uninstaller without an installer instead. When in uninstall mode, NSIS automatically copies itself into a temporary folder, runs the copy and terminates the original process. This link will give you the right idea, even though it's creating an uninstaller on its own for a different reason (i.e., so that the uninstaller can be digitally signed).
3. You could also replicate the behavior of #2 in your installer. Assuming you're using LogicLib.nsh you could add something like this to the start of your .onInit function [not tested], e.g.:
code:
${IfNot} "$EXEDIR" == "$TEMP"
CopyFiles /SILENT "$EXEPATH" "$TEMP"
Exec "$TEMP\$EXEFILE"
Quit
${EndIf}


Then delete the temporary copy on reboot by adding the following to your .onGUIEnd function if you're not using ModernUI, or to your MUI_CUSTOMFUNCTION_GUIEND defined function if you are; or alternatively to both .onInstSuccess and .onInstFailed:
code:
${If} "$EXEDIR" == "$TEMP"
Delete /REBOOTOK "$EXEPATH"
${EndIf}


pkonduru 10th November 2017 18:40

Thanks buddy for the reply! I will test out the scenarios you mentioned and see how it goes.


All times are GMT. The time now is 17:18.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.