Old 2nd November 2017, 21:41   #1
pkonduru
Member
 
Join Date: Jul 2015
Posts: 60
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?
pkonduru is offline   Reply With Quote
Old 3rd November 2017, 00:23   #2
Nutzzz
Junior Member
 
Join Date: May 2007
Location: Orange County, CA, U.S.A.
Posts: 17
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}

Nutzzz is offline   Reply With Quote
Old 10th November 2017, 19:40   #3
pkonduru
Member
 
Join Date: Jul 2015
Posts: 60
Thanks buddy for the reply! I will test out the scenarios you mentioned and see how it goes.
pkonduru is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump