forked from emesene/emesene
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemesene-installer.nsi
117 lines (92 loc) · 4.01 KB
/
emesene-installer.nsi
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
; This creats a installable version
SetCompressor lzma
!define PROGRAM_NAME "emesene"
!define PROGRAM_VERSION "2.11.6-devel"
!define PROGRAM_TYPE "installer"
!define PROGRAM_DIRECTORY "emesene2"
!define PROGRAM_SHORTCUT "emesene2"
; The name of the installer
Name "${PROGRAM_NAME} ${PROGRAM_VERSION}"
; The icon used
Icon "emesene.ico"
; The file to write
OutFile "${PROGRAM_NAME}-${PROGRAM_VERSION}-${PROGRAM_TYPE}.exe"
; License information
LicenseText "GNU General Public License"
LicenseData "GPL"
; The default installation directory
InstallDir $PROGRAMFILES\${PROGRAM_DIRECTORY}
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\${PROGRAM_DIRECTORY}" "Install_Dir"
; Pages
Page license
Page components
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
; Install (Required)
Section "Install"
SectionIn RO
; Set output path to the installation directory.
SetOutPath $INSTDIR
; Put file there
File /r "dist\*.*"
; Write the installation path into the registry
WriteRegStr HKLM SOFTWARE\${PROGRAM_DIRECTORY} "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_DIRECTORY}" "DisplayName" "${PROGRAM_NAME} ${PROGRAM_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_DIRECTORY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_DIRECTORY}" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_DIRECTORY}" "NoRepair" 1
WriteUninstaller "uninstall.exe"
SectionEnd
; Optional section (can be disabled by the user)
Section "Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\${PROGRAM_DIRECTORY}"
CreateShortCut "$SMPROGRAMS\${PROGRAM_DIRECTORY}\${PROGRAM_SHORTCUT}.lnk" "$INSTDIR\emesene.exe" "" "$INSTDIR\emesene.exe" 0
CreateShortCut "$SMPROGRAMS\${PROGRAM_DIRECTORY}\${PROGRAM_SHORTCUT} (Debug).lnk" "$INSTDIR\emesene_debug.exe" "" "$INSTDIR\emesene_debug.exe" 0
CreateShortCut "$SMPROGRAMS\${PROGRAM_DIRECTORY}\Report Issue.lnk" "https://github.com/emesene/emesene/issues"
CreateShortCut "$SMPROGRAMS\${PROGRAM_DIRECTORY}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
SectionEnd
; Optional section (can be disabled by the user)
Section "Desktop Shortcuts"
CreateShortCut "$DESKTOP\${PROGRAM_SHORTCUT}.lnk" "$INSTDIR\emesene.exe" "" "$INSTDIR\emesene.exe" 0
SectionEnd
; Uninstall
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_DIRECTORY}"
DeleteRegKey HKLM SOFTWARE\${PROGRAM_DIRECTORY}
; Remove files and uninstaller
Delete $INSTDIR\uninstall.exe
RMDir /r "$INSTDIR"
; Remove shortcuts
Delete "$DESKTOP\emesene2.lnk"
Delete "$SMPROGRAMS\${PROGRAM_DIRECTORY}\*.*"
RMDir /r "$SMPROGRAMS\${PROGRAM_DIRECTORY}"
SectionEnd
Function .onInit
; Auto-uninstall old before installing new
ReadRegStr $R0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_DIRECTORY}" \
"UninstallString"
StrCmp $R0 "" done
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"${PROGRAM_NAME} is already installed. $\n$\nClick `OK` to remove the \
previous version or `Cancel` to cancel this upgrade." \
IDOK uninst
Abort
; Run the uninstaller
uninst:
ClearErrors
ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
IfErrors no_remove_uninstaller done
;You can either use Delete /REBOOTOK in the uninstaller or add some code
;here to remove the uninstaller. Use a registry key to check
;whether the user has chosen to uninstall. If you are using an uninstaller
;components page, make sure all sections are uninstalled.
no_remove_uninstaller:
done:
FunctionEnd