Skip to content
⌘ NSIS Forum Archive

My first installer with NSIS

6 posts

oharam#

My first installer with NSIS

Hi, I'm going to do my first installer with NSIS. The installer is a Java application. The first question I have is if I add the file extension .jar or otherwise have to add the .exe extension.
I have taken as a reference for my installer this example. When run the installer, I do not get a shortcut to the application installed, what should I do to have a shortcut?

I hope your help, as I said, it's my first installer and I'm a little lost ...

Thanks.😉
Anders#
A Java application isn't the ideal starting point. Are you using a Java launcher or are you calling javaw.exe directly with all the ugly parameters?
oharam#
The code I'm working on it:

; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "SalonHabana"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "1427401697_175739.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

;OPCIONES DE LA INTERFAZ
!define MUI_HEADERIMAGE ;Habilitar imagen de cabecera.
!define MUI_HEADERIMAGE_BITMAP "imagen_cabecera.bmp" ;Imagen de cabecera del instalador. Rutas relativas.
!define MUI_HEADERIMAGE_UNBITMAP "imagen_cabecera.bmp" ;Imagen de cabecera del desinstalador.
!define MUI_WELCOMEFINISHPAGE_BITMAP "imagen_bienvenida.bmp" ;Imagen de bienvenida del instalador.
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "imagen_bienvenida.bmp" ;Imagen de bienvenida del desinstalador.


; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "licencia.txt"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "Spanish"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "SalonSetup.exe"
InstallDir "$PROGRAMFILES\SalonHabana"
ShowInstDetails show
ShowUnInstDetails show


Section "Principal" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "Salon_Habana.jar"
File /r "lib"
File "licencia.txt"

SectionEnd

Section -AdditionalIcons
CreateDirectory "$SMPROGRAMS\SalonHabana"
CreateShortCut "$SMPROGRAMS\SalonHabana\Uninstall.lnk" "$INSTDIR\uninst.exe"
CreateShortCut "$DESKTOP.lnk" "$INSTDIR\Salon_Habana.jar"
CreateShortCut "$STARTMENU.lnk" "$INSTDIR\Salon_Habana.jar"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
SectionEnd


Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK "La desinstalación de $(^Name) finalizó satisfactoriamente."
FunctionEnd

Function un.onInit
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "¿Está completamente seguro que desea desinstalar $(^Name) junto con todos sus componentes?" IDYES +2
Abort
FunctionEnd

Section Uninstall
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\Salon_Habana.jar"

Delete "$SMPROGRAMS\SalonHabana\Uninstall.lnk"
Delete "$STARTMENU.lnk"
Delete "$DESKTOP.lnk"

RMDir "$SMPROGRAMS\SalonHabana"
RMDir "$INSTDIR"
RMDir ""

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
SetAutoClose true
SectionEnd
When I run the unistall, do not delete the lib folder and the licencia.txt file.
Nor make me a shortcut icon on the desktop, as I would like.
Can anybody help?

Thanks.😉
Anders#
$DESKTOP is the path to a folder. You need to specify a filename:

CreateShortcut "$DESKTOP\MyApp.lnk" "$INSTDIR\MyApp.exe"
Creating shortcuts to .jar files is probably not a good idea, I would recommend that you use a java application launcher so you have a .exe to execute...
oharam#
Hello, the problem I have now is that I can not delete the folder of the application of Incio Menu. The lines of code which reference it is these:

Section -AdditionalIcons
CreateDirectory "$SMPROGRAMS\SalonHabana"
CreateShortCut "$SMPROGRAMS\SalonHabana\Uninstall.lnk" "$INSTDIR\uninst.exe"
CreateShortCut "$SMPROGRAMS\SalonHabana\Salon_Habana.lnk" "$INSTDIR\Salon_Habana.jar"
SectionEnd

Section -Post
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
SectionEnd
Section Uninstall
Delete "$INSTDIR\uninst.exe"
Delete "$INSTDIR\Salon_Habana.jar"
Delete "$INSTDIR\licencia.txt"

Delete "$SMPROGRAMS\SalonHabana\Uninstall.lnk"
Delete "$SMPROGRAMS\SalonHabana\Salon_Habana.lnk"

RMDIR "$SMPROGRAMS\SalonHabana"
RMDir /r "$INSTDIR"

DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
;SetAutoClose true
SectionEnd
RMDir /r "$INSTDIR" This use it to delete a folder that I have within the installed application.

Perhaps as you mention is not appropriate to do so, but I think is the most secilla to start, it's my first installer and not know the java launcher.

Thanks.😉