NSIS安装程序无法安装无人值守

时间:2015-04-21 08:05:14

标签: installer nsis silent-installer

我为.jar编写了这个小安装程序,我想在无人值守的情况下安装这个名为' baramundi'的软件分发应用程序。如果我尝试安装本地一切都很好,但如果我尝试使用相同的控制台命令的应用程序,没有安装任何东西。我做错了什么?

控制台命令是: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

1 个答案:

答案 0 :(得分:1)

IfSilent 0 +2是一个未定义的跳转,可能跳过第一节中的第一条指令,在你的情况下跳转到SetOutPath

当您不必使用标签或LogicLib时,请不要使用相对跳跃!