-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.nsi
88 lines (70 loc) · 3.26 KB
/
setup.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
!include WinVer.nsh
!define NAME "EdgeDeflectorSlim"
!define PUBLISHER "osyu"
!define URL "https://github.com/osyu/EdgeDeflectorSlim"
!define VERSION "1.0.1"
!define VERSION4 "1.0.1.0"
SetCompressor lzma
Name "${NAME}"
OutFile "${NAME}_${VERSION}_setup.exe"
VIAddVersionKey "FileDescription" "${NAME} Setup"
VIAddVersionKey "FileVersion" "${VERSION4}"
VIAddVersionKey "ProductName" "${NAME}"
VIAddVersionKey "ProductVersion" "${VERSION}"
VIProductVersion "${VERSION4}"
LicenseData "licdata.txt"
LicenseForceSelection checkbox
InstallDir "$PROGRAMFILES32\${NAME}"
Page license
Page instfiles
UninstPage uninstConfirm
UninstPage instfiles
Section
SetAutoClose true
SetOutPath $INSTDIR
File "${NAME}.exe"
File /oname=license.txt "LICENSE"
WriteUninstaller "uninst.exe"
WriteRegStr HKLM "SOFTWARE\Classes\${NAME}\Application" "ApplicationName" "${NAME}"
WriteRegStr HKLM "SOFTWARE\Classes\${NAME}\Capabilities\UrlAssociations" "microsoft-edge" "${NAME}"
WriteRegStr HKLM "SOFTWARE\Classes\${NAME}\shell\open\command" "" '"$INSTDIR\${NAME}.exe" "%1"'
WriteRegStr HKLM "SOFTWARE\RegisteredApplications" "${NAME}" "Software\Classes\${NAME}\Capabilities"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "DisplayName" "${NAME}"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "DisplayVersion" "${VERSION}"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "Publisher" "${PUBLISHER}"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "URLInfoAbout" "${URL}"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "NoModify" 1
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "NoRepair" 1
SectionGetSize 0 $0
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "EstimatedSize" $0
SectionEnd
Section "Uninstall"
SetAutoClose true
DeleteRegKey HKLM "SOFTWARE\Classes\${NAME}"
DeleteRegValue HKLM "SOFTWARE\RegisteredApplications" "${NAME}"
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
Delete "$INSTDIR\${NAME}.exe"
Delete "$INSTDIR\license.txt"
Delete "$INSTDIR\uninst.exe"
RMDir "$INSTDIR"
SectionEnd
Function .onInit
${IfNot} ${AtLeastWin10}
MessageBox MB_ICONSTOP "This application only supports Windows 10 and above."
Quit
${EndIf}
FunctionEnd
Function .onInstSuccess
HideWindow
ReadRegStr $0 HKCU "Software\Microsoft\Windows\Shell\Associations\UrlAssociations\microsoft-edge\UserChoice" "ProgId"
${If} $0 != "${NAME}"
ExecShell "open" "ms-settings:defaultapps"
MessageBox MB_ICONINFORMATION "${NAME} has been installed successfully.$\n$\n\
However, you still need to manually associate it with the microsoft-edge protocol, in order to intercept calls to Edge.$\n$\n\
This can be set in Windows settings:$\nApps > Default apps > Choose default apps by protocol."
${Else}
MessageBox MB_ICONINFORMATION "${NAME} has been installed successfully."
${EndIf}
FunctionEnd