-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwindows-installer.nsi
104 lines (73 loc) · 2.43 KB
/
windows-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
!include "MUI2.nsh"
!include "nsDialogs.nsh"
!addplugindir "plugins/"
Name "LABt v${VERSION}"
OutFile "labt-v${VERSION}_x86_64_windows-installer.exe"
InstallDir "$PROGRAMFILES\LABt\"
; Request admin
RequestExecutionLevel admin
InstallDirRegKey HKLM "Software\LABt" "Install_Dir"
; Installer icon
!define MUI_ICON "assets/icon.ico"
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
Page custom addToPathPage addToPathPageLeave
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
Var Dialog
Var Label
Var Checkbox
Var Checkbox_State
; "Add LABt to path page"
Function addToPathPage
nsDialogs::Create 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Add LABt to your current user environment PATH variable?"
Pop $Label
${NSD_CreateCheckbox} 0 12u 100% 12u "Add to PATH"
Pop $Checkbox
${If} $Checkbox_State == ${BST_CHECKED}
${NSD_Check} $Checkbox
${EndIf}
nsDialogs::Show
FunctionEnd
Function addToPathPageLeave
${NSD_GetState} $Checkbox $Checkbox_State
FunctionEnd
Section "labt (required)"
WriteRegStr HKLM SOFTWARE\LABt "Install_Dir" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LABt" "DisplayName" "LABt"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LABt" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LABt" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LABt" "NoRepair" 1
WriteUninstaller "$INSTDIR\uninstall.exe"
SetOutPath $INSTDIR
File "LICENSE"
SetOutPath "$INSTDIR\bin\"
File "labt.exe"
${If} $Checkbox_State == ${BST_CHECKED}
EnVar::SetHKCU
EnVar::AddValue "PATH" "$INSTDIR\bin"
Pop $0
DetailPrint "EnVar::AddValue returned=|$0|"
${EndIf}
SectionEnd
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LABt"
DeleteRegKey HKLM SOFTWARE\LABt
; Remove files and uninstaller
Delete $INSTDIR\bin\*
Delete $INSTDIR\*
; Remove shortcuts, if any
Delete "$SMPROGRAMS\LABt\*.lnk"
; Remove directories
RMDir "$SMPROGRAMS\LABt"
RMDir "$INSTDIR\bin"
RMDir "$INSTDIR"
SectionEnd