- NSIS Discussion
- delete setup.exe as last action?
Archive: delete setup.exe as last action?
xirisone
9th February 2007 09:11 UTC
delete setup.exe as last action?
Hi,
I need to delete my NSIS 'setup.exe' as last step of the setup itself. I can not use a BAT-file which calls setup.exe first and then deletes the file.
Can a NSIS setup delete it's own setup.exe as last action?
TIA,
xirisone
xirisone
9th February 2007 10:11 UTC
do I have to replace 'SelfDel' with the name of my MySetup.exe in your example.nsi?
!define APP_NAME SelfDel # old
!define APP_NAME MySetup # new
TIA,
xirisone (newbie)
xirisone
9th February 2007 11:00 UTC
@Takhir
got you dll working - nearly....
Problem: link and folder 'unsd' are not deleted.
My script attached. Did I include the code from your example.nsi wrongly?
TIA,
xirisone
Takhir
9th February 2007 11:14 UTC
Included sample removes uninstaller, if you want to remove setup.exe use following code
Function .onGUIEnd
SelfDel::del
FunctionEnd
but please note that in the silent mode this may not work (no function call in NSIS). The same line at the end of last mandatory section should work always, but cursor on the finish page will be with 'waiting'.
xirisone
9th February 2007 12:03 UTC
@Takhir
removing the setup.exe works fine with you example, the link and the folder 'unsd' are not deleted. Could you check my test.nsi? That would be VERY nice.
TIA,
xirisone
Takhir
9th February 2007 12:23 UTC
I guess you don't need to create links at all. The sample included to SelfDel.zip describes the most complex situation - uninstaller deletion inplace. To simulate uninstall it creates subdir, writes uninstaller and creates link (simulating start menu). You don't need this, just add the only line from my post above after # prepare automatic delete of Installer....
BTW I re-tested included to zip sample and it worked as requested.
Uninstaller auto deletes itself, this not require a plug-in.
xirisone
9th February 2007 13:00 UTC
@Takhir
You're right!!!! Just using:
Function .onGUIEnd
SelfDel::del
FunctionEnd
does the job.
Thank you VERY much!
xirisone
Red Wine
9th February 2007 21:19 UTC
Originally posted by xirisone
@Takhir
You're right!!!! Just using:
Function .onGUIEnd
SelfDel::del
FunctionEnd
does the job.
Thank you VERY much!
xirisone
What about if users for some reason decided to install the application later and click cancel e.g. on license page or components page or every included page?
It deletes the installer and nothing is installed.
Compile the following example and hit cancel on some page.
Not the best behaviour if I've downloaded a large (e.g. 100 mb) installer on a slow internet connection and I have to download again and perhaps I'll get again the same strange result.
Perhaps you should add a messagebox informing users not to click cancel otherwise they have to re-download the installer.
!define APP_NAME SelfDel
Name "${APP_NAME}"
OutFile "${APP_NAME}.exe"
InstallDir "$PROGRAMFILES\${APP_NAME}"
Page Components
Page Directory
Page InstFiles
Section "Dummy Section"
SetOutPath "$INSTDIR"
SectionEnd
Function .onGUIEnd
SelfDel::del
FunctionEnd
Takhir
10th February 2007 09:24 UTC
Just to keep xirisone informed: SelfDel plug-in page
Red Wine
10th February 2007 10:42 UTC
@ Takhir,
probably you need to update the above provided link, currently it is a link to page that doesn't exist.
Takhir
10th February 2007 10:48 UTC
Thanks, Red Wine. Updated.