Skip to content
⌘ NSIS Forum Archive

nsis uninstaller

8 posts

adnanshaheen#

nsis uninstaller

hi all,
is there any way, I can sign the uninstaller and change the icon of unsintaller. The uninstaller exe is created by nsis scipt normally, that just removes the files and shortcuts.

Thanks
adnanshaheen#
ok, I have found how to change the icon. but i'm still looking for how to sign the uninstaller?
LoRd_MuldeR#
You can't. Easily.

The Uninstaller is not a file that is packaged in your installer and which you could sign beforehand. It's a file that will be created by the installer - at install time. I think the only way is to add code to your installer that will sign Uninstall.exe after WriteUninstaller command. Of course this would require you to include your secret signing key in the installer, which is VERY insecure and makes the signature kind of meaningless... because everybody could easily take the key from the Setup.exe and then sign files in your name!

Alternative: Create the un-installer as a completely separate "installer" script, compile it, sign it and finally include it in your "main" installer like you would include any regular file. Think that's a more practical and "secure" approach...
rajansis#
Hi all,
I have created uninstaller using nsis.But i need to add my icon for the uninstaller.So in add/remove programs also should have my own icon for my uninstaller.Is there any solution ?




Thanks.
JasonFriday13#
Yes.

http://nsis.sourceforge.net/Docs/Cha...auninstallicon.

If you are using MUI:

!define MUI_UNICON "path\to\icon.ico"


In Add/Remove programs, just make the registry entry for the icon point to the uninstaller .exe.
Kuppy#
My little example can be useful
# Copyright CatsSoft
Name "Installer"
Caption "Installer"
OutFile "Installer-setup.exe"
InstallDir "$PROGRAMFILES\Installer"
# ...:: COMPRESS ::... #
SetCompressor /SOLID /FINAL lzma
# ...:: INCLUDE ::... #
!include "MUI2.nsh"
!include "WinCore.nsh"
!include "nsDialogs.nsh"
!include "LogicLib.nsh"
!include "WinMessages.nsh"
!include "FileFunc.nsh"
# ...:: RUN ::... #
RequestExecutionLevel Admin
# ...:: SHOW ::... #
ShowInstDetails hide
ShowInstDetails nevershow
ShowUnInstDetails nevershow
XPStyle off
# ...:: BRANDING ::... #
BrandingText /TRIMRIGHT " "
# ...:: ICON ::... #
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
# ...:: PAGE ::... #
Page custom "Welcome.Page" ""
Page instfiles "" "InstFilesPageShow"
Page custom "Finish.Page" ""
# ...:: UNINSTALL ::... #
!define MUI_PAGE_CUSTOMFUNCTION_SHOW "un.ModifyUnConfirm" 
!insertmacro MUI_UNPAGE_CONFIRM
!define MUI_PAGE_CUSTOMFUNCTION_SHOW "Un.InstFilesPageShow"
!insertmacro MUI_UNPAGE_INSTFILES
UninstPage custom "un.NSIS.Finish.Page" ""
# ...:: LANGUAGE ::... #
!insertmacro MUI_LANGUAGE "English"
Function .onInit
FunctionEnd
# ...:: WELCOME ::... #
Function "Welcome.Page" 
  var /GLOBAL Dialog
  var /GLOBAL Btn.Install
  GetDlgItem $0 $HWNDPARENT 1
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 2
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 3
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1990
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1991
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1992
  ShowWindow $0 ${SW_HIDE}
  System::Call "user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 779,i 512,i 0x16)"
  nsDialogs::Create 1044
  Pop $Dialog
  ${If} $Dialog == error
   Abort
  ${EndIf}
  SetCtlColors $Dialog "0x313131" "0xF5F5F5"
  System::Call "user32::MoveWindow(i$Dialog,i0,i0,i 779,i 512,i0)"
  # ...:: Install ::... #
  nsDialogs::CreateControl BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 175u 220u 175u 35u "&$(^InstallBtn)"
  Pop $Btn.Install
  StrCpy $1 $Btn.Install
  GetFunctionAddress $3 "on.Click.Install"
  nsDialogs::onClick $1 $3
  CreateFont $0 "Segoe UI" "20" "500"
  SendMessage $Btn.Install ${WM_SETFONT} $0 0
  nsDialogs::Show
FunctionEnd
# ...:: Install ::... #
Function "on.Click.Install"
  SendMessage $HWNDPARENT 0x408 1 0
FunctionEnd
# ...:: Install ::... #
Function "InstFilesPageShow"
    FindWindow $R2 "#32770" "" $HWNDPARENT
    ShowWindow $0 ${SW_HIDE}
    GetDlgItem $1 $R2 1027
    ShowWindow $1 ${SW_HIDE}
    StrCpy $R0 $R2
    System::Call "user32::MoveWindow(i R0, i 0, i 0, i 779, i 512) i r2"
    GetDlgItem $R0 $R2 1004
    SetCtlColors $R2 0x313131 0xF5F5F5
    System::Call "user32::MoveWindow(i R0, i 25, i 400, i 725, i 6) i r2"
    GetDlgItem $R1 $R2 1006
    SetCtlColors $R1 0x313131 0xF5F5F5
    System::Call "user32::MoveWindow(i R1, i 25, i 370, i 675, i 20) i r2"
    CreateFont $1 "Baar Sophia" "12" "400"
    SendMessage $R1 ${WM_SETFONT} $1 0
    GetDlgItem $R8 $R2 1016
    SetCtlColors $R8 0x313131 0xF5F5F5
    System::Call "user32::MoveWindow(i R8, i 0, i 0, i 588, i 216) i r2"
    FindWindow $R2 "#32770" "" $HWNDPARENT
    GetDlgItem $R0 $R2 1995
    System::Call "user32::MoveWindow(i R0, i 0, i 0, i 498, i 373) i r2"
    Push $0
    Push $R0
    StrCpy $R0 $R0
    # System::Call "user32::LoadImage(i 0, ts, i 0, i0, i0, i0x0010) i.r0" $PLUGINSDIR\001.bmp
    SendMessage $R0 0x0172 0 $0
    Pop $R0
    Exch $0
    FindWindow $R2 "#32770" "" $HWNDPARENT
    GetDlgItem $5 $R2 1004
    # SkinProgress::Set $5 "$PLUGINSDIR\loading2.bmp" "$PLUGINSDIR\loading1.bmp"
    w7tbp::Start
FunctionEnd
# ...:: Section ::... #
Section "$(^Name)" MAIN
   SetDetailsPrint textonly
   DetailPrint `Installing ... Please wait few moments ...`
   SetDetailsPrint listonly
   SetDetailsView hide
   SectionIn RO
   SetShellVarContext all
   SetOutPath "$INSTDIR"
   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" "DisplayName" "$(^Name)"
   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" "UninstallString" '"$INSTDIR\uninstall-$(^Name).exe"' 
   WriteUninstaller "$INSTDIR\Uninstall-$(^Name).exe"
   Sleep 500
   Sleep 500
   Sleep 500
   Sleep 500
   Sleep 500
   Sleep 5000
   Sleep 500
   Sleep 500
   Sleep 500
   Sleep 500
   Sleep 500
   SetAutoClose true
SectionEnd 
#...:: FINISH ::... #
Function "Finish.Page"
  var /GLOBAL Btn.Finish
  GetDlgItem $0 $HWNDPARENT 1
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 2
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 3
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1990
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1991
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1992
  ShowWindow $0 ${SW_HIDE}
  System::Call "user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 779,i 512,i 0x16)"
  nsDialogs::Create 1044
  Pop $Dialog
  ${If} $Dialog == error
   Abort
  ${EndIf}
  SetCtlColors $Dialog "0x313131" "0xF5F5F5"
  System::Call "user32::MoveWindow(i$Dialog,i0,i0,i 779,i 512,i0)"
  # ...:: Btn Finish ::... #
  nsDialogs::CreateControl BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 175u 220u 175u 35u "&$(^CloseBtn)"
  Pop $Btn.Finish
  StrCpy $1 $Btn.Finish
  GetFunctionAddress $3 "on.Click.Finish"
  nsDialogs::onClick $1 $3
  CreateFont $0 "Segoe UI" "20" "500"
  SendMessage $Btn.Finish ${WM_SETFONT} $0 0
  nsDialogs::Show
FunctionEnd
# ...:: Finish ::... #
Function "On.Click.Finish"
  SendMessage $HWNDPARENT 0x408 1 0
FunctionEnd
# ...:: End ::... #
Function ".onGUIEnd"
FunctionEnd
# ...:: UNINSTALL ::... #
Function 'un.onInit'
FunctionEnd
# ...:: WELCOME UNINSTALL ::... #
Function un.ModifyUnConfirm
  var /GLOBAL Un.Dialog
  var /GLOBAL Un.Btn.Uninstall
  GetDlgItem $0 $HWNDPARENT 1
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 2
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 3
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1990
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1991
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1992
  ShowWindow $0 ${SW_HIDE}
  System::Call "user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 779,i 512,i 0x16)"
  nsDialogs::Create 1044
  Pop $Un.Dialog
  ${If} $Un.Dialog == error
   Abort
  ${EndIf}
  SetCtlColors $Un.Dialog "0x313131" "0xF5F5F5"
  System::Call "user32::MoveWindow(i$Un.Dialog,i0,i0,i 779,i 512,i0)"
  # ...:: Btn Uninstall ::... #
  nsDialogs::CreateControl BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 175u 220u 175u 35u "&$(^UninstallBtn)"
  Pop $Un.Btn.Uninstall
  StrCpy $1 $Un.Btn.Uninstall
  GetFunctionAddress $3 "Un.on.Click.Uninstall"
  nsDialogs::onClick $1 $3
  CreateFont $0 "Segoe UI" "20" "500"
  SendMessage $Un.Btn.Uninstall ${WM_SETFONT} $0 0
  nsDialogs::Show
FunctionEnd
# ...:: Uninstall ::... #
Function "Un.on.Click.Uninstall"
  SendMessage $HWNDPARENT 0x408 1 0
FunctionEnd
# ...:: Uninstall ::... #
Function "Un.InstFilesPageShow"
    FindWindow $R2 "#32770" "" $HWNDPARENT
    ShowWindow $0 ${SW_HIDE}
    GetDlgItem $1 $R2 1027
    ShowWindow $1 ${SW_HIDE}
    StrCpy $R0 $R2
    System::Call "user32::MoveWindow(i R0, i 0, i 0, i 779, i 512) i r2"
    GetDlgItem $R0 $R2 1004
    SetCtlColors $R2 0x313131 0xF5F5F5
    System::Call "user32::MoveWindow(i R0, i 25, i 400, i 725, i 6) i r2"
    GetDlgItem $R1 $R2 1006
    SetCtlColors $R1 0x313131 0xF5F5F5
    System::Call "user32::MoveWindow(i R1, i 25, i 370, i 675, i 20) i r2"
    CreateFont $1 "Baar Sophia" "12" "400"
    SendMessage $R1 ${WM_SETFONT} $1 0
    GetDlgItem $R8 $R2 1016
    SetCtlColors $R8 0x313131 0xF5F5F5
    System::Call "user32::MoveWindow(i R8, i 0, i 0, i 588, i 216) i r2"
    FindWindow $R2 "#32770" "" $HWNDPARENT
    GetDlgItem $R0 $R2 1995
    System::Call "user32::MoveWindow(i R0, i 0, i 0, i 498, i 373) i r2"
    Push $0
    Push $R0
    StrCpy $R0 $R0
    # System::Call "user32::LoadImage(i 0, ts, i 0, i0, i0, i0x0010) i.r0" $PLUGINSDIR\001.bmp
    SendMessage $R0 0x0172 0 $0
    Pop $R0
    Exch $0
    FindWindow $R2 "#32770" "" $HWNDPARENT
    GetDlgItem $5 $R2 1004
    # SkinProgress::Set $5 "$PLUGINSDIR\loading2.bmp" "$PLUGINSDIR\loading1.bmp"
    w7tbp::Start
FunctionEnd
# ...:: Uninstall ::... #
Section "Uninstall"
   SetDetailsPrint textonly
   DetailPrint `Uninstalling ... Please wait few moments ...`
   SetDetailsPrint listonly
   SetDetailsView hide
   SetShellVarContext all  
   DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
   Delete "$INSTDIR\uninstall-$(^Name).exe"
   RMDir /r "$INSTDIR"
   Sleep 500
   Sleep 500
   Sleep 500
   Sleep 500
   Sleep 500
   Sleep 5000
   Sleep 500
   Sleep 500
   Sleep 500
   Sleep 500
   Sleep 500
   SetAutoClose true
SectionEnd
# ...:: FINISH Uninstall ::... #
Function "un.NSIS.Finish.Page"
  var /GLOBAL Un.Btn.Finish
  GetDlgItem $0 $HWNDPARENT 1
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 2
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 3
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1990
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1991
  ShowWindow $0 ${SW_HIDE}
  GetDlgItem $0 $HWNDPARENT 1992
  ShowWindow $0 ${SW_HIDE}
  System::Call "user32::SetWindowPos(i$HWNDPARENT,i,i,i,i 779,i 512,i 0x16)"
  nsDialogs::Create 1044
  Pop $Un.Dialog
  ${If} $Un.Dialog == error
   Abort
  ${EndIf}
  SetCtlColors $Un.Dialog "0x313131" "0xF5F5F5"
  System::Call "user32::MoveWindow(i$Un.Dialog,i0,i0,i 779,i 512,i0)"
  # ...:: Btn Finish ::... #
  nsDialogs::CreateControl BUTTON 0x40000000|0x10000000|0x04000000|0x00010000 0 175u 220u 175u 35u "&$(^CloseBtn)"
  Pop $Un.Btn.Finish
  StrCpy $1 $Un.Btn.Finish
  GetFunctionAddress $3 "un.On.Click.Finish"
  nsDialogs::onClick $1 $3
  CreateFont $0 "Segoe UI" "20" "500"
  SendMessage $Un.Btn.Finish ${WM_SETFONT} $0 0
  nsDialogs::Show
FunctionEnd
# ...:: Finish ::... #
Function "un.On.Click.Finish"
  SendMessage $HWNDPARENT 0x408 1 0
FunctionEnd
# ...:: End ::... #
Function "Un.onGUIEnd"
FunctionEnd 
JasonFriday13#
Why is that so long? And why are you using a plugin that doesn't come with NSIS? And why are you changing the dialog colours? And why are you loading images? And why are you using Sleep?????

This example is not appropriate for the question being asked.