-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
installer.nsi
145 lines (103 loc) · 3.92 KB
/
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
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
144
145
!include "MUI2.nsh"
!define setup "open-mcr_install.exe"
!define srcdir ".\dist\main"
!define company "Ian Sanders"
!define prodname "OpenMCR"
!define exec "main\main.exe"
!define icon "assets\icon.ico"
!define regkey "Software\${prodname}"
!define uninstkey "Software\Microsoft\Windows\CurrentVersion\Uninstall\${prodname}"
!define uninstaller "uninstall.exe"
; Settings ---------------------------------------------------------------------
XPStyle off
ShowInstDetails hide
ShowUninstDetails hide
Name "${prodname}"
Caption "${prodname} Installer"
!ifdef icon
Icon "${srcdir}\${icon}"
!define MUI_ICON "${srcdir}\${icon}"
!endif
OutFile "${setup}"
SetDateSave on
SetDatablockOptimize on
CRCCheck on
SilentInstall normal
InstallDir "$PROGRAMFILES\${prodname}"
InstallDirRegKey HKLM "${regkey}" ""
; MUI Settings -----------------------------------------------------------------
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Select a directory to install the program to:"
!define MUI_DIRECTORYPAGE_TEXT_TOP "This will install the ${prodname} utility to your machine.$\r$\n$\r$\nNOTE: If you encounter an 'Error opening file for writing' during installation, abort installation, restart your computer, and try again. If you encounter any futher errors, submit a bug on the project's GitHub page."
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${regkey}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
!define MUI_STARTMENUPAGE_TEXT_CHECKBOX "Don't create start menu folder"
!define MUI_FINISHPAGE_TITLE "Installation Complete"
!define MUI_FINISHPAGE_TEXT "Thank you! ${prodname} installation is complete."
!define MUI_FINISHPAGE_BUTTON "Finish"
!define MUI_FINISHPAGE_RUN "$INSTDIR\${exec}"
!define MUI_FINISHPAGE_RUN_TEXT "Run ${prodname}"
; Pages ------------------------------------------------------------------------
Var StartMenuFolder
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
UninstPage uninstConfirm
UninstPage instfiles
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
AutoCloseWindow false
ShowInstDetails show
Section
WriteRegStr HKLM "${regkey}" "Install_Dir" "$INSTDIR"
WriteRegStr HKLM "${uninstkey}" "DisplayName" "${prodname} (remove only)"
WriteRegStr HKLM "${uninstkey}" "UninstallString" '"$INSTDIR\${uninstaller}"'
WriteRegStr HKCR "${prodname}\Shell\open\command\" "" '"$INSTDIR\${exec} "%1"'
!ifdef icon
WriteRegStr HKCR "${prodname}\DefaultIcon" "" "$INSTDIR\${icon}"
!endif
SetOutPath $INSTDIR
File /a /r "${srcdir}"
!ifdef icon
File /a "${srcdir}\${icon}"
!endif
WriteUninstaller "${uninstaller}"
SectionEnd
Section
SetOutPath $INSTDIR ; for working directory
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
!ifdef icon
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${prodname}.lnk" "$INSTDIR\${exec}" "" "$INSTDIR\${icon}"
!else
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${prodname}.lnk" "$INSTDIR\${exec}"
!endif
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
; Uninstaller ------------------------------------------------------------------
UninstallText "This will uninstall ${prodname}."
!ifdef icon
UninstallIcon "${srcdir}\${icon}"
!endif
Section "Uninstall"
DeleteRegKey HKLM "${uninstkey}"
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
Delete "$SMPROGRAMS\$StartMenuFolder\*.*"
Delete "$SMPROGRAMS\$StartMenuFolder"
!ifdef licensefile
Delete "$INSTDIR\${licensefile}"
!endif
!ifdef notefile
Delete "$INSTDIR\${notefile}"
!endif
!ifdef icon
Delete "$INSTDIR\${icon}"
!endif
Delete "$INSTDIR"
!ifdef unfiles
!include "${unfiles}"
!endif
DeleteRegKey HKLM "${regkey}"
SectionEnd