-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNSIS Installer for LWAR.nsi
168 lines (132 loc) · 6.02 KB
/
NSIS Installer for LWAR.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
; LWAR Installer NSIS Script
; get NSIS at http://nsis.sourceforge.net/Download
!define ProgramName "LWAR"
!define ProgramVersion 1.0.0.0
Icon "LWAR\Resources\1400410576_24736.ico"
Name "${ProgramName}"
Caption "${ProgramName} Installer"
XPStyle on
Unicode true
ShowInstDetails show
AutoCloseWindow true
VIProductVersion ${ProgramVersion}
VIAddVersionKey "ProductVersion" "${ProgramVersion}"
VIAddVersionKey "ProductName" "${ProgramName}"
VIAddVersionKey "FileVersion" "${ProgramVersion}"
VIAddVersionKey "LegalCopyright" "FOSS Walkman"
VIAddVersionKey "FileDescription" "${ProgramName} Installer"
LicenseBkColor /windows
LicenseData "LICENSE"
LicenseForceSelection checkbox "I have read and understand this notice"
LicenseText "Please read the notice below before installing ${ProgramName}. If you understand the notice, click the checkbox below and click Next."
InstallDir $PROGRAMFILES\DeavmiOSS
OutFile "LWAR\bin\Release\${ProgramName}-Installer.exe"
; Pages
Page license
Page components
Page directory
Page instfiles
Page custom postInstallShow postInstallFinish ": Install Complete"
UninstPage uninstConfirm
UninstPage instfiles
; Sections
Section "Executable & Uninstaller"
SectionIn RO
SetOutPath $INSTDIR
File "LWAR\bin\Release\${ProgramName}.exe"
WriteUninstaller "${ProgramName}-Uninst.exe"
SectionEnd
Section "Add to Windows Programs & Features"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProgramName}" "DisplayName" "${ProgramName}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProgramName}" "Publisher" "DeavmiOSS"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProgramName}" "DisplayIcon" "$INSTDIR\${ProgramName}.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProgramName}" "InstallLocation" "$INSTDIR\"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProgramName}" "UninstallString" "$INSTDIR\${ProgramName}-Uninst.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProgramName}" "DisplayVersion" "${ProgramVersion}"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProgramName}" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProgramName}" "NoRepair" 1
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProgramName}" "HelpLink" "https://github.com/Walkman-Mirror/${ProgramName}/issues/new"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProgramName}" "URLInfoAbout" "https://github.com/Walkman-Mirror/${ProgramName}" ; Support Link
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProgramName}" "URLUpdateInfo" "https://github.com/Walkman-Mirror/${ProgramName}/releases" ; Update Info Link
SectionEnd
Section "Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\DeavmiOSS"
CreateShortCut "$SMPROGRAMS\DeavmiOSS\${ProgramName}.lnk" "$INSTDIR\${ProgramName}.exe" "" "$INSTDIR\${ProgramName}.exe" "" "" "" "Start Launch With Admin Rights (LWAR)"
CreateShortCut "$SMPROGRAMS\DeavmiOSS\Uninstall ${ProgramName}.lnk" "$INSTDIR\${ProgramName}-Uninst.exe" "" "" "" "" "" "Uninstall Launch With Admin Rights (LWAR)"
; Syntax for CreateShortCut: link.lnk target.file [parameters [icon.file [icon_index_number [start_options [keyboard_shortcut [description]]]]]]
SectionEnd
Section "Desktop Shortcut"
CreateShortCut "$DESKTOP\${ProgramName}.lnk" "$INSTDIR\${ProgramName}.exe" "" "$INSTDIR\${ProgramName}.exe" "" "" "" "Launch With Admin Rights (LWAR)"
SectionEnd
Section "Quick Launch Shortcut"
CreateShortCut "$QUICKLAUNCH\${ProgramName}.lnk" "$INSTDIR\${ProgramName}.exe" "" "$INSTDIR\${ProgramName}.exe" "" "" "" "Launch With Admin Rights (LWAR)"
SectionEnd
; Functions
Function .onInit
SetShellVarContext all
SetAutoClose true
FunctionEnd
; Custom Install Complete page
!include nsDialogs.nsh
!include LogicLib.nsh ; For ${IF} logic
Var Dialog
Var Label
Var CheckboxReadme
Var CheckboxReadme_State
Var CheckboxRunProgram
Var CheckboxRunProgram_State
Function postInstallShow
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Setup will launch these tasks when you click close:"
Pop $Label
${NSD_CreateCheckbox} 10u 30u 100% 10u "&Open Wiki"
Pop $CheckboxReadme
${If} $CheckboxReadme_State == ${BST_CHECKED}
${NSD_Check} $CheckboxReadme
${EndIf}
${NSD_CreateCheckbox} 10u 50u 100% 10u "&Launch ${ProgramName}"
Pop $CheckboxRunProgram
${If} $CheckboxRunProgram_State == ${BST_CHECKED}
${NSD_Check} $CheckboxRunProgram
${EndIf}
# alternative for the above ${If}:
#${NSD_SetState} $Checkbox_State
nsDialogs::Show
FunctionEnd
Function postInstallFinish
${NSD_GetState} $CheckboxReadme $CheckboxReadme_State
${NSD_GetState} $CheckboxRunProgram $CheckboxRunProgram_State
${If} $CheckboxReadme_State == ${BST_CHECKED}
ExecShell "open" "https://github.com/Walkman-Mirror/${ProgramName}/wiki"
${EndIf}
${If} $CheckboxRunProgram_State == ${BST_CHECKED}
ExecShell "open" "$INSTDIR\${ProgramName}.exe"
${EndIf}
FunctionEnd
; Uninstaller
Section "Uninstall"
Delete "$INSTDIR\${ProgramName}-Uninst.exe" ; Remove Application Files
Delete "$INSTDIR\${ProgramName}.exe"
RMDir "$INSTDIR"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${ProgramName}" ; Remove Windows Programs & Features integration (uninstall info)
Delete "$SMPROGRAMS\DeavmiOSS\${ProgramName}.lnk" ; Remove Start Menu Shortcuts & Folder
Delete "$SMPROGRAMS\DeavmiOSS\Uninstall ${ProgramName}.lnk"
RMDir "$SMPROGRAMS\DeavmiOSS"
Delete "$DESKTOP\${ProgramName}.lnk" ; Remove Desktop Shortcut
Delete "$QUICKLAUNCH\${ProgramName}.lnk" ; Remove Quick Launch shortcut
SectionEnd
; Uninstaller Functions
Function un.onInit
SetShellVarContext all
SetAutoClose true
FunctionEnd
Function un.onUninstFailed
MessageBox MB_OK "Uninstall Cancelled"
FunctionEnd
Function un.onUninstSuccess
MessageBox MB_OK "Uninstall Completed"
FunctionEnd