4
4
!define DEFAULTPORTABLEDESTINATON " $Desktop\${NAME}"
5
5
Name " ${NAME}"
6
6
Outfile " ${NAME} setup.exe"
7
- RequestExecutionlevel highest
8
- ; RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)
9
- SetCompressor LZMA
7
+ ; RequestExecutionlevel highest
8
+ RequestExecutionLevel admin ; Require admin rights on NT6+ (When UAC is turned on)
9
+ ; SetCompressor LZMA
10
+ SetCompress Off
10
11
11
12
Var NormalDestDir
12
13
Var PortableDestDir
@@ -25,140 +26,154 @@ Page Custom PortableModePageCreate PortableModePageLeave
25
26
26
27
27
28
Function .onInit
28
- Call RequireAdmin
29
- StrCpy $NormalDestDir " ${DEFAULTNORMALDESTINATON}"
30
- StrCpy $PortableDestDir " ${DEFAULTPORTABLEDESTINATON}"
31
-
32
- ${GetParameters} $9
33
-
34
- ClearErrors
35
- ${GetOptions} $9 " /?" $8
36
- ${IfNot} ${Errors}
37
- MessageBox MB_ICONINFORMATION |MB_SETFOREGROUND " \
38
- /PORTABLE : Extract application to USB drive etc$\n \
39
- /S : Silent install$\n \
40
- /D=%directory% : Specify destination directory$\n "
41
- Quit
42
- ${EndIf}
43
-
44
- ClearErrors
45
- ${GetOptions} $9 " /PORTABLE" $8
46
- ${IfNot} ${Errors}
47
- StrCpy $PortableMode 1
48
- StrCpy $0 $PortableDestDir
49
- ${Else}
50
- StrCpy $PortableMode 0
51
- StrCpy $0 $NormalDestDir
52
- ${If} ${Silent}
53
- Call RequireAdmin
29
+ Call RequireAdmin
30
+ StrCpy $NormalDestDir " ${DEFAULTNORMALDESTINATON}"
31
+ StrCpy $PortableDestDir " ${DEFAULTPORTABLEDESTINATON}"
32
+
33
+ ${GetParameters} $9
34
+
35
+ ClearErrors
36
+ ${GetOptions} $9 " /?" $8
37
+ ${IfNot} ${Errors}
38
+ MessageBox MB_ICONINFORMATION |MB_SETFOREGROUND " \
39
+ /PORTABLE : Extract application to USB drive etc$\n \
40
+ /S : Silent install$\n \
41
+ /D=%directory% : Specify destination directory$\n "
42
+ Quit
43
+ ${EndIf}
44
+
45
+ ClearErrors
46
+ ${GetOptions} $9 " /PORTABLE" $8
47
+ ${IfNot} ${Errors}
48
+ StrCpy $PortableMode 1
49
+ StrCpy $0 $PortableDestDir
50
+ ${Else}
51
+ StrCpy $PortableMode 0
52
+ StrCpy $0 $NormalDestDir
53
+ ${If} ${Silent}
54
+ Call RequireAdmin
55
+ ${EndIf}
54
56
${EndIf}
55
- ${EndIf}
56
-
57
- ${If} $InstDir == " "
58
- ; User did not use /D to specify a directory,
59
- ; we need to set a default based on the install mode
60
- StrCpy $InstDir $0
61
- ${EndIf}
62
- Call SetModeDestinationFromInstdir
57
+
58
+ ${If} $InstDir == " "
59
+ ; User did not use /D to specify a directory,
60
+ ; we need to set a default based on the install mode
61
+ StrCpy $InstDir $0
62
+ ${EndIf}
63
+ Call SetModeDestinationFromInstdir
63
64
FunctionEnd
64
65
65
66
66
67
Function RequireAdmin
67
- UserInfo::GetAccountType
68
- Pop $8
69
- ${If} $8 != " admin"
70
- MessageBox MB_ICONSTOP " You need administrator rights to install ${NAME}"
71
- SetErrorLevel 740 ; ERROR_ELEVATION_REQUIRED
72
- Abort
73
- ${EndIf}
68
+ UserInfo::GetAccountType
69
+ Pop $8
70
+ ${If} $8 != " admin"
71
+ MessageBox MB_ICONSTOP " You need administrator rights to install ${NAME}"
72
+ SetErrorLevel 740 ; ERROR_ELEVATION_REQUIRED
73
+ Abort
74
+ ${EndIf}
74
75
FunctionEnd
75
76
76
77
77
78
Function SetModeDestinationFromInstdir
78
- ${If} $PortableMode = 0
79
- StrCpy $NormalDestDir $InstDir
80
- ${Else}
81
- StrCpy $PortableDestDir $InstDir
82
- ${EndIf}
79
+ ${If} $PortableMode = 0
80
+ StrCpy $NormalDestDir $InstDir
81
+ ${Else}
82
+ StrCpy $PortableDestDir $InstDir
83
+ ${EndIf}
83
84
FunctionEnd
84
85
85
86
86
87
Function PortableModePageCreate
87
- Call SetModeDestinationFromInstdir ; If the user clicks BACK on the directory page we will remember their mode specific directory
88
- !insertmacro MUI_HEADER_TEXT " Install Mode" " Choose how you want to install ${NAME}."
89
- nsDialogs::Create 1018
90
- Pop $0
91
- ${NSD_CreateLabel} 0 10u 100 % 24u " Select install mode:"
92
- Pop $0
93
- ${NSD_CreateRadioButton} 30u 50u -30u 8u " Normal install"
94
- Pop $1
95
- ${NSD_CreateRadioButton} 30u 70u -30u 8u " Portable"
96
- Pop $2
97
- ${If} $PortableMode = 0
98
- SendMessage $1 ${BM_SETCHECK} ${BST_CHECKED} 0
99
- ${Else}
100
- SendMessage $2 ${BM_SETCHECK} ${BST_CHECKED} 0
101
- ${EndIf}
102
- nsDialogs::Show
88
+ Call SetModeDestinationFromInstdir ; If the user clicks BACK on the directory page we will remember their mode specific directory
89
+ !insertmacro MUI_HEADER_TEXT " Install Mode" " Choose how you want to install ${NAME}."
90
+ nsDialogs::Create 1018
91
+ Pop $0
92
+ ${NSD_CreateLabel} 0 10u 100 % 24u " Select install mode:"
93
+ Pop $0
94
+ ${NSD_CreateRadioButton} 30u 50u -30u 8u " Normal install"
95
+ Pop $1
96
+ ${NSD_CreateRadioButton} 30u 70u -30u 8u " Portable"
97
+ Pop $2
98
+ ${If} $PortableMode = 0
99
+ SendMessage $1 ${BM_SETCHECK} ${BST_CHECKED} 0
100
+ ${Else}
101
+ SendMessage $2 ${BM_SETCHECK} ${BST_CHECKED} 0
102
+ ${EndIf}
103
+ nsDialogs::Show
103
104
FunctionEnd
104
105
105
106
Function PortableModePageLeave
106
- ${NSD_GetState} $1 $0
107
- ${If} $0 <> ${BST_UNCHECKED}
108
- StrCpy $PortableMode 0
109
- StrCpy $InstDir $NormalDestDir
110
- Call RequireAdmin
111
- ${Else}
112
- StrCpy $PortableMode 1
113
- StrCpy $InstDir $PortableDestDir
114
- ${EndIf}
107
+ ${NSD_GetState} $1 $0
108
+ ${If} $0 <> ${BST_UNCHECKED}
109
+ StrCpy $PortableMode 0
110
+ StrCpy $InstDir $NormalDestDir
111
+ Call RequireAdmin
112
+ ${Else}
113
+ StrCpy $PortableMode 1
114
+ StrCpy $InstDir $PortableDestDir
115
+ ${EndIf}
115
116
FunctionEnd
116
117
117
118
118
119
119
120
Section
120
- SetOutPath " $InstDir"
121
- File " relaykeysd-service-restart.bat"
122
- File /r dist\relaykeysd\*
123
- SetShellVarContext all
124
- ; create start-menu items
125
- CreateDirectory " $SMPROGRAMS\Ace Centre\RelayKeys"
126
- CreateShortCut " $SMPROGRAMS\Ace Centre\RelayKeys\RelayKeys.lnk" " $INSTDIR\relaykeys-qt.exe" " " " $INSTDIR\relaykeys-qt.exe" 0
127
- CreateShortCut " $SMPROGRAMS\Ace Centre\RelayKeys\RelayKeys-Config.lnk" " $INSTDIR\relaykeys.cfg" " " " $INSTDIR\relaykeys.cfg" 0
128
- CreateShortCut " $SMPROGRAMS\Ace Centre\RelayKeys\Help.lnk" " $INSTDIR\README.html" " " " $INSTDIR\README.html" 0
129
- CreateShortCut " $SMPROGRAMS\Ace Centre\RelayKeys\Uninstall.lnk" " $INSTDIR\Uninstall.exe" " " " $INSTDIR\Uninstall.exe" 0
130
- CreateShortCut " $SMPROGRAMS\Ace Centre\RelayKeys\Restart-RelayKeys.lnk" " $INSTDIR\relaykeysd-service-restart.bat" " " " $INSTDIR\relaykeysd-service-restart.bat" 0
131
- CreateShortcut " $DESKTOP\RelayKeys-QT.lnk" " $INSTDIR\relaykeys-qt.exe"
132
-
133
- ; SimpleSC Plugin: https://nsis.sourceforge.io/NSIS_Simple_Service_Plugin
134
- SimpleSC::InstallService " RelayKeysDaemon" " Relay Keys Daemon" 16 2 ' "$INSTDIR\relaykeysd-service.exe"'
135
- Pop $0
136
- SimpleSC::StartService " RelayKeysDaemon" " " 30
137
- Pop $0
138
-
139
- ${If} $PortableMode = 0
140
- WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTKEY}" " DisplayName" " ${NAME}"
141
- WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTKEY}" " UninstallString" ' "$INSTDIR\uninstall.exe"'
142
- WriteUninstaller " $INSTDIR\uninstall.exe"
143
- ${Else}
144
- ; Create the file the application uses to detect portable mode
145
- FileOpen $0 " $INSTDIR\portable.dat" w
146
- FileWrite $0 " PORTABLE"
147
- FileClose $0
148
- ${EndIf}
121
+ SimpleSC::ExistsService " RelayKeysDaemon"
122
+ Pop $0
123
+ ${If} $0 == 0
124
+ SimpleSC::ServiceIsRunning " RelayKeysDaemon"
125
+ Pop $0
126
+ Pop $1
127
+ ${If} $0 == 0
128
+ ${If} $1 == 1
129
+ ; MessageBox MB_OK "Service exists and running"
130
+ SimpleSC::StopService " RelayKeysDaemon" 10 30
131
+ ${EndIf}
132
+ ${EndIf}
133
+ ${EndIf}
134
+
135
+ SetOutPath " $InstDir"
136
+ File " relaykeysd-service-restart.bat"
137
+ File /r dist\relaykeysd\*
138
+ SetShellVarContext all
139
+ ; create start-menu items
140
+ CreateDirectory " $SMPROGRAMS\Ace Centre\RelayKeys"
141
+ CreateShortCut " $SMPROGRAMS\Ace Centre\RelayKeys\RelayKeys.lnk" " $INSTDIR\relaykeys-qt.exe" " " " $INSTDIR\relaykeys-qt.exe" 0
142
+ CreateShortCut " $SMPROGRAMS\Ace Centre\RelayKeys\RelayKeys-Config.lnk" " $INSTDIR\relaykeys.cfg" " " " $INSTDIR\relaykeys.cfg" 0
143
+ CreateShortCut " $SMPROGRAMS\Ace Centre\RelayKeys\Help.lnk" " $INSTDIR\README.html" " " " $INSTDIR\README.html" 0
144
+ CreateShortCut " $SMPROGRAMS\Ace Centre\RelayKeys\Uninstall.lnk" " $INSTDIR\Uninstall.exe" " " " $INSTDIR\Uninstall.exe" 0
145
+ CreateShortCut " $SMPROGRAMS\Ace Centre\RelayKeys\Restart-RelayKeys.lnk" " $INSTDIR\relaykeysd-service-restart.bat" " " " $INSTDIR\relaykeysd-service-restart.bat" 0
146
+ CreateShortcut " $DESKTOP\RelayKeys-QT.lnk" " $INSTDIR\relaykeys-qt.exe"
147
+
148
+ ; SimpleSC Plugin: https://nsis.sourceforge.io/NSIS_Simple_Service_Plugin
149
+ SimpleSC::InstallService " RelayKeysDaemon" " Relay Keys Daemon" 16 2 ' "$INSTDIR\relaykeysd-service.exe"'
150
+ Pop $0
151
+ SimpleSC::StartService " RelayKeysDaemon" " " 30
152
+ Pop $0
153
+
154
+ ${If} $PortableMode = 0
155
+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTKEY}" " DisplayName" " ${NAME}"
156
+ WriteRegStr HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTKEY}" " UninstallString" ' "$INSTDIR\uninstall.exe"'
157
+ WriteUninstaller " $INSTDIR\uninstall.exe"
158
+ ${Else}
159
+ ; Create the file the application uses to detect portable mode
160
+ FileOpen $0 " $INSTDIR\portable.dat" w
161
+ FileWrite $0 " PORTABLE"
162
+ FileClose $0
163
+ ${EndIf}
149
164
SectionEnd
150
165
151
166
152
167
Section Uninstall
153
- DeleteRegKey HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTKEY}"
154
- SimpleSC::StopService " RelayKeysDaemon" 10 30
155
- SimpleSC::RemoveService " RelayKeysDaemon"
156
- Delete " $INSTDIR\uninstall.exe"
157
- Delete " $SMPROGRAMS\Ace Centre\RelayKeys\RelayKeys.lnk"
158
- Delete " $SMPROGRAMS\Ace Centre\RelayKeys\Help.lnk"
159
- Delete " $SMPROGRAMS\Ace Centre\RelayKeys\Uninstall.lnk"
160
- Delete " $SMPROGRAMS\Ace Centre\RelayKeys\Restart-RelayKeys.lnk"
161
- Delete " $SMPROGRAMS\Ace Centre\RelayKeys\Restart-Config.lnk"
162
- Delete " $DESKTOP\RelayKeys-QT.lnk"
163
- RMDir /r " $INSTDIR"
168
+ DeleteRegKey HKLM " Software\Microsoft\Windows\CurrentVersion\Uninstall\${UNINSTKEY}"
169
+ SimpleSC::StopService " RelayKeysDaemon" 10 30
170
+ SimpleSC::RemoveService " RelayKeysDaemon"
171
+ Delete " $INSTDIR\uninstall.exe"
172
+ Delete " $SMPROGRAMS\Ace Centre\RelayKeys\RelayKeys.lnk"
173
+ Delete " $SMPROGRAMS\Ace Centre\RelayKeys\Help.lnk"
174
+ Delete " $SMPROGRAMS\Ace Centre\RelayKeys\Uninstall.lnk"
175
+ Delete " $SMPROGRAMS\Ace Centre\RelayKeys\Restart-RelayKeys.lnk"
176
+ Delete " $SMPROGRAMS\Ace Centre\RelayKeys\Restart-Config.lnk"
177
+ Delete " $DESKTOP\RelayKeys-QT.lnk"
178
+ RMDir /r " $INSTDIR"
164
179
SectionEnd
0 commit comments