forked from electron-userland/electron-builder
-
Notifications
You must be signed in to change notification settings - Fork 3
/
common.nsh
116 lines (100 loc) · 2.92 KB
/
common.nsh
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
!include x64.nsh
!include WinVer.nsh
BrandingText "${PRODUCT_NAME} ${VERSION}"
ShowInstDetails nevershow
SpaceTexts none
!ifdef BUILD_UNINSTALLER
ShowUninstDetails nevershow
!endif
FileBufSize 64
Name "${PRODUCT_NAME}"
!define ENABLE_LOGGING
!define APP_EXECUTABLE_FILENAME "${PRODUCT_FILENAME}.exe"
!define UNINSTALL_FILENAME "Uninstall ${PRODUCT_FILENAME}.exe"
!macro check64BitAndSetRegView
# https://github.com/electron-userland/electron-builder/issues/2420
${If} ${IsWin2000}
${OrIf} ${IsWinME}
${OrIf} ${IsWinXP}
${OrIf} ${IsWinVista}
MessageBox MB_OK "$(win7Required)"
Quit
${EndIf}
!ifdef APP_ARM64
${If} ${RunningX64}
SetRegView 64
${EndIf}
${If} ${IsNativeARM64}
SetRegView 64
${EndIf}
!else
!ifdef APP_64
${If} ${RunningX64}
SetRegView 64
${Else}
!ifndef APP_32
MessageBox MB_OK|MB_ICONEXCLAMATION "$(x64WinRequired)"
Quit
!endif
${EndIf}
!endif
!endif
!macroend
# avoid exit code 2
!macro quitSuccess
SetErrorLevel 0
Quit
!macroend
!macro setLinkVars
# old desktop shortcut (could exist or not since the user might has selected to delete it)
ReadRegStr $oldShortcutName SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" ShortcutName
${if} $oldShortcutName == ""
StrCpy $oldShortcutName "${PRODUCT_FILENAME}"
${endIf}
StrCpy $oldDesktopLink "$DESKTOP\$oldShortcutName.lnk"
# new desktop shortcut (will be created/renamed in case of a fresh installation or if the user haven't deleted the initial one)
StrCpy $newDesktopLink "$DESKTOP\${SHORTCUT_NAME}.lnk"
ReadRegStr $oldMenuDirectory SHELL_CONTEXT "${INSTALL_REGISTRY_KEY}" MenuDirectory
${if} $oldMenuDirectory == ""
StrCpy $oldStartMenuLink "$SMPROGRAMS\$oldShortcutName.lnk"
${else}
StrCpy $oldStartMenuLink "$SMPROGRAMS\$oldMenuDirectory\$oldShortcutName.lnk"
${endIf}
# new menu shortcut (will be created/renamed in case of a fresh installation or if the user haven't deleted the initial one)
!ifdef MENU_FILENAME
StrCpy $newStartMenuLink "$SMPROGRAMS\${MENU_FILENAME}\${SHORTCUT_NAME}.lnk"
!else
StrCpy $newStartMenuLink "$SMPROGRAMS\${SHORTCUT_NAME}.lnk"
!endif
!macroend
!macro skipPageIfUpdated
!define UniqueID ${__LINE__}
Function skipPageIfUpdated_${UniqueID}
${if} ${isUpdated}
Abort
${endif}
FunctionEnd
!define MUI_PAGE_CUSTOMFUNCTION_PRE skipPageIfUpdated_${UniqueID}
!undef UniqueID
!macroend
!macro StartApp
Var /GLOBAL startAppArgs
${if} ${isUpdated}
StrCpy $startAppArgs "--updated"
${else}
StrCpy $startAppArgs ""
${endif}
${StdUtils.ExecShellAsUser} $0 "$launchLink" "open" "$startAppArgs"
!macroend
!define LogSet "!insertmacro LogSetMacro"
!macro LogSetMacro SETTING
!ifdef ENABLE_LOGGING
LogSet ${SETTING}
!endif
!macroend
!define LogText "!insertmacro LogTextMacro"
!macro LogTextMacro INPUT_TEXT
!ifdef ENABLE_LOGGING
LogText ${INPUT_TEXT}
!endif
!macroend