Skip to content

Instantly share code, notes, and snippets.

@malfario
Last active December 13, 2017 09:28
Show Gist options
  • Save malfario/25e9d8fc69ed3034eb74 to your computer and use it in GitHub Desktop.
Save malfario/25e9d8fc69ed3034eb74 to your computer and use it in GitHub Desktop.
NSIS basic script
;##
# Project info.
# @author <author>
#;
!define APPNAME "APPNAME"
!define VERSION "0.1"
!define PUBLISHER "Humano Software S.L."
!define APPNAMEANDVERSION "${APPNAME} ${VERSION}"
!define /date CURRENT_YEAR "%Y"
Name "${APPNAMEANDVERSION}"
InstallDir "$PROGRAMFILES\${APPNAME}"
OutFile "dist\${APPNAME}-setup.exe"
SetCompressor LZMA
ShowInstDetails show
ShowUnInstDetails show
RequestExecutionLevel admin
!include "MUI.nsh"
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\${APPNAME}.exe"
!define MUI_FINISHPAGE_RUN_TEXT "Ejecutar ${APPNAMEANDVERSION}"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_RESERVEFILE_LANGDLL
!if ! /FileExists 'dist'
!system 'mkdir dist'
!endif
Section "Files" Files
SetOutPath "$INSTDIR"
File "${APPNAME}.exe"
SectionEnd
Section -Shortcuts
CreateDirectory "$SMPROGRAMS\${APPNAME}"
CreateShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\${APPNAME}.exe"
CreateShortCut "$SMPROGRAMS\${APPNAME}\Desinstalar ${APPNAME}.lnk" "$INSTDIR\uninstall.exe"
SectionEnd
Section -Registry
WriteRegStr HKLM "Software\${APPNAME}" "" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayVersion" "${VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayIcon" "$INSTDIR\${APPNAME}.exe,0"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "Publisher" "${PUBLISHER}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$INSTDIR\uninstall.exe"
WriteUninstaller "$INSTDIR\uninstall.exe"
SectionEnd
Section Uninstall
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"
DeleteRegKey HKLM "SOFTWARE\${APPNAME}"
Delete "$INSTDIR\uninstall.exe"
Delete "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk"
Delete "$SMPROGRAMS\${APPNAME}\Desinstalar ${APPNAME}.lnk"
Delete /REBOOTOK "$INSTDIR\${APPNAME}.exe"
RMDir "$SMPROGRAMS\${APPNAME}"
RMDir "$INSTDIR"
SectionEnd
BrandingText "(c)${CURRENT_YEAR} ${PUBLISHER}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment