Alaska
Alaska

Reputation: 1

NSIS Installer wont install unattended

I wrote this little installer for a .jar and i want to install this programm unattended with software distribution application called 'baramundi'. If i try the installation local everything is fine but if i try it with the application with the same console command there is nothing installed. What am i doing wrong?

The console command is: SetupCSVExporter.exe /S

!define PRODUCT_NAME "CSVExporter"
!define PRODUCT_VERSION "1.3"
!define PRODUCT_PUBLISHER "Company"
!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 "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; 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 "German"

var ISSILENT

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "SetupCSVExporter.exe"
InstallDir "$DESKTOP\CSVExporter"
ShowInstDetails show
ShowUnInstDetails show
; Problemlösung: Delete Startmenu Shortcut
RequestExecutionLevel user

Section "Hauptgruppe" SEC01
  SetOutPath "$INSTDIR"
  SetOverwrite ifnewer
  File "CSVExporter.jar"
  CreateDirectory "$SMPROGRAMS\CSVExporter"
  CreateShortCut "$SMPROGRAMS\CSVExporter\CSVExporter.lnk" "$INSTDIR\CSVExporter.jar"
SectionEnd

Section -AdditionalIcons
  CreateShortCut "$SMPROGRAMS\CSVExporter\Uninstall.lnk" "$INSTDIR\uninst.exe"
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}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd
; Problemlösung: SILENT Installation
Function .onInit

 STRCpy $ISSILENT "/S"
 IfSilent 0 +2

FunctionEnd

Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) wurde erfolgreich deinstalliert."
FunctionEnd

Function un.onInit
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Möchten Sie $(^Name) und alle seinen Komponenten deinstallieren?" IDYES +2
  Abort
FunctionEnd

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

  Delete "$SMPROGRAMS\CSVExporter\Uninstall.lnk"
  Delete "$SMPROGRAMS\CSVExporter\CSVExporter.lnk"

  RMDir "$SMPROGRAMS\CSVExporter"
  RMDir "$INSTDIR"

  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  SetAutoClose true
SectionEnd

Upvotes: 0

Views: 241

Answers (1)

Anders
Anders

Reputation: 101636

IfSilent 0 +2 is a undefined jump, it probably jumps over the first instruction in the First Section and in your case that is SetOutPath!

Don't use relative jumps when you don't have to, use labels or the LogicLib!

Upvotes: 1

Related Questions