Old 26th March 2015, 09:18   #1
oharam
Junior Member
 
Join Date: Mar 2015
Posts: 4
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.
oharam is offline   Reply With Quote
Old 26th March 2015, 13:03   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
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?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 26th March 2015, 14:56   #3
oharam
Junior Member
 
Join Date: Mar 2015
Posts: 4
The code I'm working on it:

code:
; 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.
oharam is offline   Reply With Quote
Old 26th March 2015, 19:46   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
$DESKTOP is the path to a folder. You need to specify a filename:

Quote:
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...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 26th March 2015, 20:09   #5
oharam
Junior Member
 
Join Date: Mar 2015
Posts: 4
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:

code:
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



code:
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.
oharam is offline   Reply With Quote
Old 26th March 2015, 20:36   #6
oharam
Junior Member
 
Join Date: Mar 2015
Posts: 4
Smile

I managed to delete the folder in the menu incio thanks to this post.
oharam is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump