Skip to content
⌘ NSIS Forum Archive

How can I create an uninstaller?

12 posts

Angry Coder#

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.
amckern#
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
JasonFriday13#
WriteUninstaller "$INSTDIR\uninstall.exe"
CreateShortCut "$SMPROGRAMS\Your Program Folder\Uninstall Your Program.lnk" "$INSTDIR\uninstall.exe"
Angry Coder#
I got this error:

Error: no Uninstall section specified, but WriteUninstaller used 1 time(s)
Error - aborting creation process
JasonFriday13#
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
Angry Coder#
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.
JasonFriday13#
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
onad#
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.