-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.nsi
More file actions
140 lines (120 loc) · 3.83 KB
/
setup.nsi
File metadata and controls
140 lines (120 loc) · 3.83 KB
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
ShowInstDetails nevershow
ShowUninstDetails nevershow
;--------------------------------
; Includes
!include "MUI2.nsh"
!include "logiclib.nsh"
;--------------------------------
; Custom defines
; Đổi tên ứng dụng của bạn
!define NAME "Tên app của bạn"
; File .exe trong folder app
!define APPFILE "File.exe bên trong folder app"
; Phiên bản ứng dụng
!define VERSION "Phiên bản"
!define SLUG "${NAME} v${VERSION}"
!define UNINSTALL "Uninstall"
;--------------------------------
; General
Unicode true
Name "${NAME}"
OutFile "${NAME} v${VERSION} Setup.exe"
InstallDir "$PROGRAMFILES\${NAME}\"
InstallDirRegKey HKCU "Software\${NAME}" ""
RequestExecutionLevel admin
;--------------------------------
; UI
; Icon ứng dụng
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-colorful.ico"
; Icon gỡ cài đặt ứng dụng
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-colorful.ico"
!define MUI_HEADERIMAGE
; Ảnh góc bên trái
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\win.bmp"
; Ảnh trên đầu
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\win.bmp"
!define MUI_ABORTWARNING
!define MUI_WELCOMEPAGE_TITLE "${SLUG} Setup"
;--------------------------------
; Pages
; Installer pages
!insertmacro MUI_PAGE_WELCOME
; !insertmacro MUI_PAGE_LICENSE "license.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
; Uninstaller pages
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
; Set UI language
!insertmacro MUI_LANGUAGE "Vietnamese"
;--------------------------------
; Section - Install App
Section "-hidden app"
SetDetailsPrint none
SectionIn RO
SetOutPath "$INSTDIR"
File /r "app\*.*"
WriteRegStr HKCU "Software\${NAME}" "" $INSTDIR
WriteUninstaller "$INSTDIR\${UNINSTALL}.exe"
SectionEnd
;--------------------------------
; Section - Shortcut
Section "Desktop Shortcut" DeskShort
SetDetailsPrint none
CreateShortCut "$DESKTOP\${NAME}.lnk" "$INSTDIR\${APPFILE}"
SectionEnd
;--------------------------------
; Section - Startmenu
Section "Startmenu Shortcut" StartShort
SetDetailsPrint none
CreateDirectory "$SMPrograms\${NAME}"
CreateShortcut "$SMPrograms\${NAME}\${NAME}.lnk" "$InstDir\${APPFILE}"
CreateShortCut "$SMPrograms\${NAME}\${UNINSTALL}.lnk" "$InstDir\${UNINSTALL}.exe"
SectionEnd
;--------------------------------
; Descriptions
;Language strings
LangString DESC_DeskShort 1066 "Create shortcut in Desktop."
LangString DESC_StartShort 1066 "Create shortcut in Start menu."
;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${DeskShort} $(DESC_DeskShort)
!insertmacro MUI_DESCRIPTION_TEXT ${StartShort} $(DESC_StartShort)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
; Remove empty parent directories
Function un.RMDirUP
!define RMDirUP '!insertmacro RMDirUPCall'
!macro RMDirUPCall _PATH
push '${_PATH}'
Call un.RMDirUP
!macroend
; $0 - current folder
ClearErrors
Exch $0
;DetailPrint "ASDF - $0\.."
RMDir "$0\.."
IfErrors Skip
${RMDirUP} "$0\.."
Skip:
Pop $0
FunctionEnd
;--------------------------------
; Section - Uninstaller
Section "Uninstall"
SetDetailsPrint none
;Delete Shortcut
Delete "$DESKTOP\${NAME}.lnk"
;Delete StartMenu
Delete "$SMPrograms\${NAME}\${Name}.lnk"
Delete "$SMPrograms\${NAME}\${UNINSTALL}.lnk"
Delete "$SMPrograms\${NAME}"
;Delete Uninstall
Delete "$INSTDIR\Uninstall.exe"
;Delete Folder
RMDir /r "$INSTDIR"
${RMDirUP} "$INSTDIR"
DeleteRegKey /ifempty HKCU "Software\${NAME}"
SectionEnd