Archive: How can I create an uninstaller?


How can I create an uninstaller?
Hi!

I am very new with NSIS. And I have a simple setup program that does the following:

- Create directory on My Programs and copy a single file
- Create a a shortcut on Startup folder

How can I create an uninstaller and place it under My Programs?

Thanks.


I dont know how to do this, but...

For complex applactions

I would recomend you use the wizzard applaction called HM NIS Edit from http://hmne.sourceforge.net/

Just chose file>new script from wizzard and folow the prompts


WriteUninstaller "$INSTDIR\uninstall.exe"
CreateShortCut "$SMPROGRAMS\Your Program Folder\Uninstall Your Program.lnk" "$INSTDIR\uninstall.exe"

whoa, that simplie - dam NSIS is rather good


I got this error:

Error: no Uninstall section specified, but WriteUninstaller used 1 time(s)
Error - aborting creation process


Section Uninstall

Delete ...etc

SectionEnd

-Stu


Delete what? :(


The uninstaller does not make a list of files and registry keys to delete when installing. You must delete the files manually in the uninstaller. You must also have some uninstaller pages, too.


UninstPage confirm
UninstPage instfiles

Section Uninstall
Delete "$INSTDIR\programfile1.txt"
Delete "$INSTDIR\programfile2.txt"
Delete "$INSTDIR\programfile3.txt"
Delete "$INSTDIR\programfile4.txt"
Delete "$INSTDIR\uninstall.exe"
RMDir "$INSTDIR"
SetAutoClose false
SectionEnd

Thanks but this is not working:

Section "Uninstall"

Delete "$INSTDIR\Uninstall My Program.exe"
Delete "$INSTDIR\My Program.exe"
RMDir $INSTDIR
Delete "$SMSTARTUP\My Program.lnk" <------- Everything is ok, except this line. It doesn't remove the shortcut!

SectionEnd

Please help. Thanks.


Please don't double post. I have stated this on the other post you made.

I don't know why but it should work. This basic script works:


Name "Delete Startup File"
OutFile "Delete Startup File.exe"

InstallDir "$PROGRAMFILES\myapp"

Page directory
Page instfiles
UninstPage instfiles

Section
SetOutPath "$INSTDIR"
CreateShortCut "$SMSTARTUP\Uninstall this app.lnk" "$INSTDIR\uninstall.exe"
WriteUninstaller "$INSTDIR\uninstall.exe"
SectionEnd

Section Uninstall
Delete "$SMSTARTUP\Uninstall this app.lnk"
Delete "$INSTDIR\uninstall.exe"
RMDir "$INSTDIR"
SectionEnd

The following was missing:

SetShellVarContext all

:)


Hi AngryCoder,

IMHO I think you could benefit from trying the NSIS examples first, then look in the code and improve your installer script by borrowing example snippetes of code.