File: NullsoftInstaller.nsi

package info (click to toggle)
charmtimetracker 1.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,340 kB
  • sloc: cpp: 19,176; xml: 284; python: 120; makefile: 14
file content (143 lines) | stat: -rw-r--r-- 3,627 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
; basic script template for NullsoftInstallerPackager
;
; Copyright 2016-2018 Hannnah von Reth <hannah.vonreth@kdab.com>
; Copyright 2010 Patrick Spendrin <ps_ml@gmx.de>


!include MUI2.nsh
!include LogicLib.nsh


; registry stuff
!define regkey "Software\${companyName}\${productName}"
!define uninstkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productName}"

!define startmenu "$SMPROGRAMS\${productName}"
!define uninstaller "uninstall.exe"

Var StartMenuFolder

;Start Menu Folder Page Configuration
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${regkey}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"

;--------------------------------


XPStyle on
ShowInstDetails hide
ShowUninstDetails hide

SetCompressor /SOLID lzma

Name "${productName}"
Caption "Installing ${productName}"

OutFile "${setupname}"

!define MUI_ICON ${applicationIcon}

!insertmacro MUI_PAGE_WELCOME

${productLicence}

!insertmacro MUI_PAGE_DIRECTORY

!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_PAGE_FINISH

;uninstaller
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;-------

!insertmacro MUI_LANGUAGE "English"

SetDateSave on
SetDatablockOptimize on
CRCCheck on
SilentInstall normal

InstallDir "${programFilesDir}\${productName}"
InstallDirRegKey HKLM "${regkey}" ""


;--------------------------------
AutoCloseWindow false


; beginning (invisible) section
Section "--hidden ${productName}" BASE
   SectionIn RO
   SetOutPath $INSTDIR
   SetShellVarContext all

    WriteRegStr HKLM "${regkey}" "Install_Dir" "$INSTDIR"
    WriteRegStr HKLM "${regkey}" "Version" "${productVersion}"
    WriteRegStr HKLM "${regkey}" "" "$INSTDIR\uninstall.exe"

    WriteRegStr HKLM "${uninstkey}" "DisplayName" "${productName} (remove only)"
    WriteRegStr HKLM "${uninstkey}" "DisplayIcon" "$INSTDIR\${applicationName}"
    WriteRegStr HKLM "${uninstkey}" "DisplayVersion" "${productVersion}"
    WriteRegStr HKLM "${uninstkey}" "UninstallString" '"$INSTDIR\${uninstaller}"'
    WriteRegStr HKLM "${uninstkey}" "Publisher" "${companyName}"

  SetOutPath $INSTDIR


    ; package all files, recursively, preserving attributes
    ; assume files are in the correct places

    File /a /r /x "*.nsi" /x "${setupname}" "${deployDir}\*.*"

    !if "${vcredist}" != "none"
        ExecWait '"$INSTDIR\${vcredist}" /passive'
        Delete "$INSTDIR\${vcredist}"
    !endif


    WriteUninstaller "${uninstaller}"


    ;Create shortcuts
    !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
        CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
        CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${productName}.lnk" "$INSTDIR\${applicationName}"
    !insertmacro MUI_STARTMENU_WRITE_END
SectionEnd

; Uninstaller
; All section names prefixed by "Un" will be in the uninstaller

UninstallText "This will uninstall ${productName}."

Section "Uninstall"
    SetShellVarContext all
    SetShellVarContext all

    DeleteRegKey HKLM "${uninstkey}"
    DeleteRegKey HKLM "${regkey}"

    !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder

    RMDir /r "$SMPROGRAMS\$StartMenuFolder"
    RMDir /r "$INSTDIR"
SectionEnd


Function .onInit
    ReadRegStr $R0 HKLM "${uninstkey}" "UninstallString"
    StrCmp $R0 "" done
    ReadRegStr $INSTDIR HKLM "${regkey}" "Install_Dir"
    ;Run the uninstaller
    ;uninst:
    ClearErrors
    ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
    done:
FunctionEnd