Skip to content

Commit 30779a2

Browse files
richardetcRichardTea
authored andcommitted
Fix Windows firewall rules and uninstaller
1 parent a725bc5 commit 30779a2

File tree

2 files changed

+47
-62
lines changed

2 files changed

+47
-62
lines changed

install/win/install.nsi

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
; limitations under the License.
1616

1717
SetCompressor /SOLID lzma
18+
RequestExecutionLevel admin
1819

1920
!define PRODUCT_NAME "sACNView"
2021
!define PRODUCT_PUBLISHER "Tom Steer"
@@ -66,23 +67,6 @@ InstallDirRegKey ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "InstallDir"
6667

6768
!insertmacro MUI_PAGE_WELCOME
6869

69-
; Check for Admin rights
70-
Section CheckAdmin
71-
DetailPrint "Checking Admin Rights"
72-
System::Call "kernel32::GetModuleHandle(t 'shell32.dll') i .s"
73-
System::Call "kernel32::GetProcAddress(i s, i 680) i .r0"
74-
System::Call "::$0() i .r0"
75-
76-
IntCmp $0 0 isNotAdmin isNotAdmin isAdmin
77-
isNotAdmin:
78-
DetailPrint "Missing Administrator Rights !!!"
79-
messageBox MB_OK "You do not have Administrator rights on this computer.$\r$\r\
80-
Please log in as an administrator to install sACNView."
81-
quit
82-
isAdmin:
83-
DetailPrint "Administrator Rights granted"
84-
SectionEnd
85-
8670
!insertmacro MUI_PAGE_DIRECTORY
8771
!insertmacro MUI_PAGE_INSTFILES
8872
!define MUI_FINISHPAGE_RUN $INSTDIR\${PRODUCT_NAME}.exe
@@ -128,7 +112,13 @@ Section "Main Application" sec01
128112
;Same as create shortcut you need to use ${UNINST_EXE} instead of anything else.
129113
WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "UninstallString" "${UNINST_EXE}"
130114

131-
SimpleFC::AddApplication "sACNView" "$INSTDIR\sACNView.exe" 0 2 "" 1
115+
DetailPrint "Adding Firewall Exception"
116+
; rule_name, description, protocol, direction,
117+
; status, profiles, action, application,
118+
; service_name, icmp_types_and_codes, group, local_ports, remote_ports, local_address, remote_address
119+
SimpleFC::AdvAddRule ${PRODUCT_NAME} "${PRODUCT_NAME} UDP Multicast Receive" "17" \
120+
"1" "1" "2147483647" "1" "$INSTDIR\sACNView.exe" \
121+
"" "" "@$INSTDIR\sACNView.exe,-10000" "" "" "" ""
132122
Pop $0
133123

134124
IntCmp $0 0 fw_ok
@@ -165,21 +155,23 @@ FunctionEnd
165155
#######################################################################################
166156

167157
Section UnInstall
158+
;uninstall from path, must be repeated for every install logged path individual
159+
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR"
168160

169-
;begin uninstall, especially for MUI could be added in UN.onInit function instead
170-
;!insertmacro UNINSTALL.LOG_BEGIN_UNINSTALL
171-
172-
;uninstall from path, must be repeated for every install logged path individual
173-
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR"
161+
;end uninstall, after uninstall from all logged paths has been performed
162+
!insertmacro UNINSTALL.LOG_END_UNINSTALL
174163

175-
;end uninstall, after uninstall from all logged paths has been performed
176-
!insertmacro UNINSTALL.LOG_END_UNINSTALL
164+
; Remove firewall exception
165+
SimpleFC::AdvRemoveRule ${PRODUCT_NAME}
177166

178-
Delete "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk"
179-
Delete "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk"
180-
RmDir "$SMPROGRAMS\${PRODUCT_NAME}"
167+
DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "InstallDir"
168+
DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "DisplayIcon"
169+
DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "DisplayName"
170+
DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "DisplayVersion"
171+
DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "Publisher"
172+
DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "UninstallString"
181173

182-
DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
174+
DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
183175

184176
SectionEnd
185177

install/win64/install.nsi

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
Unicode true
1818

1919
SetCompressor /SOLID lzma
20+
RequestExecutionLevel admin
2021

2122
!define PRODUCT_NAME "sACNView64"
2223
!define PRODUCT_PUBLISHER "Tom Steer"
@@ -69,23 +70,6 @@ InstallDirRegKey ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "InstallDir"
6970

7071
!insertmacro MUI_PAGE_WELCOME
7172

72-
; Check for Admin rights
73-
Section CheckAdmin
74-
DetailPrint "Checking Admin Rights"
75-
System::Call "kernel32::GetModuleHandle(t 'shell32.dll') i .s"
76-
System::Call "kernel32::GetProcAddress(i s, i 680) i .r0"
77-
System::Call "::$0() i .r0"
78-
79-
IntCmp $0 0 isNotAdmin isNotAdmin isAdmin
80-
isNotAdmin:
81-
DetailPrint "Missing Administrator Rights !!!"
82-
messageBox MB_OK "You do not have Administrator rights on this computer.$\r$\r\
83-
Please log in as an administrator to install sACNView."
84-
quit
85-
isAdmin:
86-
DetailPrint "Administrator Rights granted"
87-
SectionEnd
88-
8973
!insertmacro MUI_PAGE_DIRECTORY
9074
!insertmacro MUI_PAGE_INSTFILES
9175
!define MUI_FINISHPAGE_RUN $INSTDIR\sACNView.exe
@@ -132,8 +116,13 @@ Section "Main Application" sec01
132116
;Same as create shortcut you need to use ${UNINST_EXE} instead of anything else.
133117
WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "UninstallString" "${UNINST_EXE}"
134118

135-
; Add firewall exception
136-
SimpleFC::AddApplication ${PRODUCT_NAME} "$INSTDIR\sACNView.exe" 0 2 "" 1
119+
DetailPrint "Adding Firewall Exception"
120+
; rule_name, description, protocol, direction,
121+
; status, profiles, action, application,
122+
; service_name, icmp_types_and_codes, group, local_ports, remote_ports, local_address, remote_address
123+
SimpleFC::AdvAddRule ${PRODUCT_NAME} "${PRODUCT_NAME} UDP Multicast Receive" "17" \
124+
"1" "1" "2147483647" "1" "$INSTDIR\sACNView.exe" \
125+
"" "" "@$INSTDIR\sACNView.exe,-10000" "" "" "" ""
137126
Pop $0
138127

139128
IntCmp $0 0 fw_ok
@@ -176,22 +165,26 @@ Section UnInstall
176165
; Use the 64bit registry
177166
SetRegView 64
178167

179-
;begin uninstall, especially for MUI could be added in UN.onInit function instead
180-
;!insertmacro UNINSTALL.LOG_BEGIN_UNINSTALL
168+
;uninstall from path, must be repeated for every install logged path individual
169+
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR"
170+
171+
;end uninstall, after uninstall from all logged paths has been performed
172+
!insertmacro UNINSTALL.LOG_END_UNINSTALL
181173

182-
;uninstall from path, must be repeated for every install logged path individual
183-
!insertmacro UNINSTALL.LOG_UNINSTALL "$INSTDIR"
174+
Delete "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk"
175+
RmDir "$SMPROGRAMS\${PRODUCT_NAME}"
184176

185-
;end uninstall, after uninstall from all logged paths has been performed
186-
!insertmacro UNINSTALL.LOG_END_UNINSTALL
177+
; Remove firewall exception
178+
SimpleFC::AdvRemoveRule ${PRODUCT_NAME}
187179

188-
Delete "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk"
189-
RmDir "$SMPROGRAMS\${PRODUCT_NAME}"
190-
191-
; Remove firewall exception
192-
SimpleFC::RemoveApplication "$INSTDIR\sACNView.exe"
180+
DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "InstallDir"
181+
DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "DisplayIcon"
182+
DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "DisplayName"
183+
DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "DisplayVersion"
184+
DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "Publisher"
185+
DeleteRegValue ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "UninstallString"
193186

194-
DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
187+
DeleteRegKey /ifempty ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
195188

196189
SectionEnd
197190

@@ -200,7 +193,7 @@ Function UN.onInit
200193
; Use the 64bit registry
201194
SetRegView 64
202195

203-
;begin uninstall, could be added on top of uninstall section instead
204-
!insertmacro UNINSTALL.LOG_BEGIN_UNINSTALL
196+
;begin uninstall, could be added on top of uninstall section instead
197+
!insertmacro UNINSTALL.LOG_BEGIN_UNINSTALL
205198

206199
FunctionEnd

0 commit comments

Comments
 (0)