简体   繁体   English

NSIS安装程序不会自动安装

[英]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'. 我为.jar编写了这个小安装程序,我想在一个名为'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 控制台命令是: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

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 ! IfSilent 0 +2是未定义的跳转,则它可能会跳过“第一部分”中的第一条指令,在您的情况下为SetOutPath

Don't use relative jumps when you don't have to, use labels or the LogicLib! 不必使用相对跳转,不必使用标签或LogicLib!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM