-
Notifications
You must be signed in to change notification settings - Fork 1
/
portmaster-installer.nsi
146 lines (119 loc) · 4.88 KB
/
portmaster-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
145
146
Unicode true
!define PRODUCT_VERSION "1.0.13.0"
!define VERSION "1.0.13.0"
VIProductVersion "${PRODUCT_VERSION}"
VIFileVersion "${VERSION}"
VIAddVersionKey "ProductName" "Portmaster"
VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
VIAddVersionKey "FileDescription" "Portmaster Application Firewall"
VIAddVersionKey "FileVersion" "${VERSION}"
VIAddVersionKey "CompanyName" "Safing ICS Technologies GmbH"
VIAddVersionKey "LegalCopyright" "Safing ICS Technologies GmbH"
!define MUI_ICON "portmaster.ico"
!define MUI_UNICON "portmaster.ico"
!define MUI_HEADERIMAGE
!include MUI2.nsh
!include nsDialogs.nsh
!include LogicLib.nsh
!include WinVer.nsh
!include x64.nsh
!include shortcut-properties.nsh
Name "Portmaster"
OutFile "portmaster-installer-offline.exe"
SetCompressor /SOLID lzma
!define ProgrammFolderLink "$Programfiles64\Safing\Portmaster.lnk"
!define Parent_ProgrammFolderLink "$Programfiles64\Safing"
!define ExeName "portmaster-start.exe"
!define LogoName "portmaster.ico"
!define SnoreToastExe "SnoreToast.exe"
!define MUI_ABORTWARNING
!define MUI_LANGDLL_ALLLANGUAGES
Var InstDir_parent
;;
; Pages
;;
!insertmacro MUI_PAGE_LICENSE "LICENSE.txt"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!include languages.nsh
Function .onInit
ReadEnvStr $0 PROGRAMDATA
StrCpy $InstDir "$0\Safing\Portmaster"
StrCpy $InstDir_parent "$0\Safing"
SetRebootFlag true
FunctionEnd
Section "Install"
SetOutPath $INSTDIR
SetShellVarContext all
IfFileExists "$Programfiles64\Safing\Portmaster" 0 noAncientUpdate
DetailPrint "Removing old Portmaster Files"
RMDIR /R "$SMPROGRAMS\Portmaster"
Delete "$SMSTARTUP\Portmaster Notifier.lnk"
RMDir /R /REBOOTOK "$Programfiles64\Safing\Portmaster"
noAncientUpdate:
IfFileExists "$INSTDIR\${ExeName}" 0 dontUpdate
DetailPrint "Removing old Portmaster Files"
Delete "$INSTDIR\${ExeName}.bak"
Rename "$INSTDIR\${ExeName}" "$INSTDIR\${ExeName}.bak"
Delete /REBOOTOK "$INSTDIR\${ExeName}.bak"
dontUpdate:
File "${ExeName}"
File "${LogoName}"
File "portmaster-uninstaller.exe"
CreateDirectory "${Parent_ProgrammFolderLink}"
CreateShortcut "${ProgrammFolderLink}" "$InstDir"
SetShellVarContext all
CreateDirectory "$SMPROGRAMS\Portmaster"
CreateShortcut "$SMPROGRAMS\Portmaster\Portmaster.lnk" "$INSTDIR\${ExeName}" "app --data=$InstDir" "$INSTDIR\portmaster.ico"
CreateShortcut "$SMPROGRAMS\Portmaster\Portmaster Notifier.lnk" "$INSTDIR\${ExeName}" "notifier --data=$InstDir" "$INSTDIR\portmaster.ico"
CreateShortcut "$SMSTARTUP\Portmaster Notifier.lnk" "$INSTDIR\${ExeName}" "notifier --data=$InstDir" "$INSTDIR\portmaster.ico"
!insertmacro ShortcutSetToastProperties "$SMPROGRAMS\Portmaster\Portmaster.lnk" "{7F00FB48-65D5-4BA8-A35B-F194DA7E1A51}" "io.safing.portmaster"
pop $0
${If} $0 <> 0
MessageBox MB_ICONEXCLAMATION "Shortcut-Attributes to enable Toast Messages could not be set"
SetErrors
Abort
${EndIf}
DetailPrint "Sucessfully added Shortcut-Attributes for Toast Messages. Return Code: $0 (0: S_OK)"
WriteRegStr HKLM "SOFTWARE\Classes\CLSID\{7F00FB48-65D5-4BA8-A35B-F194DA7E1A51}\LocalServer32" "" '"$INSTDIR\${ExeName}" notifier-snoretoast'
; prepare directory structure
nsExec::ExecToStack '$INSTDIR\${ExeName} clean-structure --data=$InstDir'
pop $0
pop $1
DetailPrint "Prepared the installation directory."
; Copy Portmaster directory
DetailPrint "Copying Portmaster directory..."
SetOutPath "$INSTDIR"
SetOverwrite on
File /r ".\Portmaster\*.*"
DetailPrint "Successfully copied Portmaster."
; register Service
nsExec::ExecToStack '$INSTDIR\${ExeName} install core-service --data=$InstDir'
pop $0
pop $1
DetailPrint $1
${If} $0 <> 0
MessageBox MB_ICONEXCLAMATION "Windows Service registration failed. Please contact our support at support@safing.io."
SetErrors
Abort
${EndIf}
DetailPrint "Successfully registered Portmaster as a Windows Service."
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Portmaster" \
"DisplayName" "Portmaster"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Portmaster" \
"DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Portmaster" \
"UninstallString" "$\"$INSTDIR\portmaster-uninstaller.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Portmaster" \
"InstallLocation" "$\"$INSTDIR$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Portmaster" \
"DisplayIcon" "$\"$INSTDIR\portmaster.ico$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Portmaster" \
"Publisher" "Safing ICS Technologies GmbH"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Portmaster" \
"HelpLink" "https://safing.io"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Portmaster" \
"NoRepair" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Portmaster" \
"NoModify" 1
SectionEnd