forked from jlaine/wilink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wilink.nsi.in
133 lines (106 loc) · 3.8 KB
/
wilink.nsi.in
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
!define PRODUCT_NAME "wiLink"
Name "${PRODUCT_NAME}"
OutFile "${PRODUCT_OUTPUT}"
SetCompressor lzma
InstallDir "$PROGRAMFILES\wiLink"
!include "MUI.nsh"
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE}"
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_FINISHPAGE_RUN "$INSTDIR\bin\wiLink.exe";
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "French"
RequestExecutionLevel admin
VIProductVersion ${PRODUCT_VERSION}.0
VIAddVersionKey CompanyName "Wifirst"
VIAddVersionKey FileDescription "${PRODUCT_NAME} ${PRODUCT_VERSION}"
VIAddVersionKey FileVersion "${PRODUCT_VERSION}"
VIAddVersionKey LegalCopyright "Copyright 2009-2015 Wifirst"
VIAddVersionKey ProductName "${PRODUCT_NAME}"
VIAddVersionKey ProductVersion "${PRODUCT_VERSION}"
Function ConditionalAddToRegisty
Pop $0
Pop $1
StrCmp "$0" "" ConditionalAddToRegisty_EmptyString
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\wiLink" \
"$1" "$0"
;MessageBox MB_OK "Set Registry: '$1' to '$0'"
DetailPrint "Set install registry entry: '$1' to '$0'"
ConditionalAddToRegisty_EmptyString:
FunctionEnd
Section "-Core installation"
;Use the entire tree produced by the INSTALL target. Keep the
;list of directories here in sync with the RMDir commands below.
SetOutPath "$INSTDIR"
;Make sure program is closed
ExecWait '"taskkill.exe" /F /IM wiLink.exe' $0
Sleep 1000
;Remove old registry keys
DeleteRegKey SHCTX "Software\Humanity\wiLink 1.1.0"
DeleteRegKey SHCTX "Software\Humanity\wiLink 2.0.1"
DeleteRegKey SHCTX "Software\Humanity\wiLink 2.1.0"
DeleteRegKey SHCTX "Software\Wifirst\wiLink 2.1.901"
DeleteRegKey SHCTX "Software\Wifirst\wiLink 2.1.902"
;Remove old files
;File /r "${INST_DIR}\*.*"
File /r bin
;Store installation folder
WriteRegStr SHCTX "Software\Wifirst\wiLink" "" $INSTDIR
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
Push "DisplayIcon"
Push "$INSTDIR\bin\wiLink.exe"
Call ConditionalAddToRegisty
Push "DisplayName"
Push "${PRODUCT_NAME}"
Call ConditionalAddToRegisty
Push "DisplayVersion"
Push "${PRODUCT_VERSION}"
Call ConditionalAddToRegisty
Push "Publisher"
Push "Wifirst"
Call ConditionalAddToRegisty
Push "UninstallString"
Push "$INSTDIR\Uninstall.exe"
Call ConditionalAddToRegisty
Push "NoRepair"
Push "1"
Call ConditionalAddToRegisty
;Create shortcuts
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\wiLink.lnk" "$INSTDIR\bin\wiLink.exe"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
;Add protocol handler
WriteRegStr HKCR "wilink" "" "URL:wilink"
WriteRegStr HKCR "wilink" "URL Protocol" ""
WriteRegStr HKCR "wilink\shell" "" ""
WriteRegStr HKCR "wilink\shell\open" "" ""
WriteRegStr HKCR "wilink\shell\open\command" "" "$INSTDIR\bin\wiLink.exe %1"
;In silent mode, automatically run program
IfSilent 0 +2
Exec "$INSTDIR\bin\wiLink.exe"
SectionEnd
Section "Uninstall"
;Purge program data
RMDir /r "$LOCALAPPDATA\Wifirst\wiLink"
RMDir "$LOCALAPPDATA\Wifirst"
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "wiLink"
DeleteRegKey HKCU "Software\Wifirst\wiLink"
DeleteRegKey /ifempty HKCU "Software\Wifirst"
; Remove protocol handler
DeleteRegKey HKCR "wilink"
;Remove the uninstaller itself.
Delete "$INSTDIR\Uninstall.exe"
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\wiLink"
;Remove the installation directory.
RMDir /r "$INSTDIR"
; Remove the registry entries.
DeleteRegKey SHCTX "Software\Wifirst\wiLink"
; Remove shortcuts.
RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}"
Push $INSTDIR\bin
SectionEnd