-
Notifications
You must be signed in to change notification settings - Fork 2
/
make_installer.nsi
144 lines (116 loc) · 4.02 KB
/
make_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
; Build Unicode installer
Unicode True
!include "LogicLib.nsh"
!include "StrFunc.nsh"
${StrLoc}
!define VERSION "1.0.10" ; Se incrementa automáticamente por bump2version
LoadLanguageFile "${NSISDIR}\Contrib\Language files\Spanish.nlf"
; Nombre del instalador
Name "AntTracker v${VERSION}"
; Nombre de archivo del instalador
OutFile "AntTracker_v${VERSION}_installer.exe"
; Request application privileges for Windows Vista and higher
RequestExecutionLevel admin
; The default installation directory
InstallDir $PROGRAMFILES64\AntTracker
; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\AntTracker" "Install_Dir"
;--------------------------------
; Pages
Page license
LicenseData "LICENSE"
Page components
Page directory
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
!define PathUnquoteSpaces '!insertmacro PathUnquoteSpaces '
Function PathUnquoteSpaces
Exch $0
Push $1
StrCpy $1 $0 1
StrCmp $1 '"' 0 ret
StrCpy $1 $0 "" -1
StrCmp $1 '"' 0 ret
StrCpy $0 $0 -1 1
ret:
Pop $1
Exch $0
FunctionEnd
!macro PathUnquoteSpaces var
Push ${var}
Call PathUnquoteSpaces
Pop ${var}
!macroend
;--------------------------------
; The "" makes the section hidden.
Section "" SecUninstallPrevious
SectionIn RO
; Check for uninstaller.
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AntTracker" "Install_Dir"
${If} $R0 == ""
Goto Done
${EndIf}
${PathUnquoteSpaces} $R0
RMDir /r $R0
Done:
SectionEnd
; The stuff to install
Section "AntTracker & AntLabeler (requerido)"
SectionIn RO
; Agregar forzosamente la carpeta \AntTracker al directorio
; de instalación si el usuario no lo especifica
${StrLoc} $0 $INSTDIR "\AntTracker" ">"
${If} $0 == ""
${StrLoc} $0 "$INSTDIR" "\" "<"
${If} $0 != 0
StrCpy $INSTDIR "$INSTDIR\AntTracker"
${Else}
StrCpy $INSTDIR "$INSTDIRAntTracker"
${EndIf}
${EndIf}
SetOutPath $INSTDIR
; Put files there
File /r "dist\AntTracker\*"
; Write the installation path into the registry
WriteRegStr HKLM "Software\AntTracker" "Install_Dir" "$INSTDIR"
; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AntTracker" "DisplayName" "AntTracker"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AntTracker" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AntTracker" "Install_Dir" '"$INSTDIR"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AntTracker" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AntTracker" "NoRepair" 1
WriteUninstaller "$INSTDIR\uninstall.exe"
SectionEnd
Section "Visual C++ Redistributable para Visual Studio 2017"
SectionIn RO
NSISdl::download https://aka.ms/vs/15/release/vc_redist.x64.exe "$INSTDIR\vc_redist.x64.exe"
ExecWait '"$INSTDIR\vc_redist.x64.exe" /install /passive /norestart'
SectionEnd
Section "Accesos directos (Menu Inicio)"
CreateDirectory "$SMPROGRAMS\AntTracker"
CreateShortcut "$SMPROGRAMS\AntTracker\Uninstall.lnk" "$INSTDIR\uninstall.exe"
CreateShortcut "$SMPROGRAMS\AntTracker\AntTracker.lnk" "$INSTDIR\AntTracker.exe"
CreateShortcut "$SMPROGRAMS\AntTracker\AntLabeler.lnk" "$INSTDIR\AntLabeler.exe"
SectionEnd
Section /o "Accesos directos (Escritorio)"
CreateShortcut "$DESKTOP\AntTracker.lnk" "$INSTDIR\AntTracker.exe"
CreateShortcut "$DESKTOP\AntLabeler.lnk" "$INSTDIR\AntLabeler.exe"
SectionEnd
;--------------------------------
; Uninstaller
Section "Uninstall"
; Remove registry keys
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AntTracker"
DeleteRegKey HKLM "Software\AntTracker"
; Remove files and uninstaller
Delete "$INSTDIR\*"
; Remove shortcuts, if any
Delete "$SMPROGRAMS\AntTracker\*.lnk"
Delete "$DESKTOP\AntTracker.lnk"
Delete "$DESKTOP\AntLabeler.lnk"
; Remove directories
RMDir "$SMPROGRAMS\AntTracker"
RMDir /r "$INSTDIR"
SectionEnd