Archive: delete setup.exe as last action?


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


http://forums.winamp.com/showthread....hlight=selfdel


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)


@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


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'.

@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


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.


@Takhir
You're right!!!! Just using:

Function .onGUIEnd
SelfDel::del
FunctionEnd

does the job.
Thank you VERY much!

xirisone


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

Just to keep xirisone informed: SelfDel plug-in page


@ Takhir,
probably you need to update the above provided link, currently it is a link to page that doesn't exist.


Thanks, Red Wine. Updated.