The Windows installer is the framework's: a setup run again opens the installed app
packages/waybetter/windows/installer.nsi (shipped in the npm package) is the NSIS template wayBetter for X used, made generic: an app that was renamed keeps its registry keys by defining WAYBETTER_LEGACY_NAME in its installer hooks; without it the keys are Tauri's defaults. Run by hand (no /UPDATE) it installs only when it is newer than what is installed. With the same or a newer version installed it installs nothing, opens the installed exe (the single-instance guard shows the running window) and exits 0, so an old setup can no longer replace or downgrade an install the updater has moved on. /FORCE reinstalls the same version, /NORUN is kept, the updater path is unchanged. create-waybetter apps use the template (bundle.windows.nsis, per-user). wayBetter for X's page is waybetter.fyi/x in the READMEs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5a2e959763
commit
479d3d0019
6 changed files with 920 additions and 2 deletions
11
README.md
11
README.md
|
|
@ -36,7 +36,7 @@ License: GPL-3.0-or-later.
|
||||||
|
|
||||||
| Project | Target | What it is |
|
| Project | Target | What it is |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| [wayBetter for X](https://waybetter.fyi/twttr/) | x.com (website) | Desktop app around the live X: tabs, split panes, real accounts side by side, themes, plugins, drafts and fixes for X's own bugs. The first wayBetter app. |
|
| [wayBetter for X](https://waybetter.fyi/x/) | x.com (website) | Desktop app around the live X: tabs, split panes, real accounts side by side, themes, plugins, drafts and fixes for X's own bugs. The first wayBetter app. |
|
||||||
|
|
||||||
Built something on wayBetter? Add it to this list with a pull request: name and link, what it extends, one line on what it does.
|
Built something on wayBetter? Add it to this list with a pull request: name and link, what it extends, one line on what it does.
|
||||||
|
|
||||||
|
|
@ -355,6 +355,15 @@ The npm package adds the app-side tooling:
|
||||||
`<outDir>/upload`, `latest.json` (other platforms of the version kept); macOS: signs a universal
|
`<outDir>/upload`, `latest.json` (other platforms of the version kept); macOS: signs a universal
|
||||||
build's updater bundle and adds both darwin platforms. It never uploads: it prints the steps.
|
build's updater bundle and adds both darwin platforms. It never uploads: it prints the steps.
|
||||||
The key is read only into the build's environment or handed to the Tauri signer by path.
|
The key is read only into the build's environment or handed to the Tauri signer by path.
|
||||||
|
- `waybetter/windows/installer.nsi`: the Windows installer, a template for Tauri's NSIS bundler
|
||||||
|
(`bundle.windows.nsis.template`). No wizard and no UAC: it installs for the current user, makes
|
||||||
|
the Desktop and Start menu shortcuts and opens the app. Run again by hand, it only installs when
|
||||||
|
it is newer than what is installed (an upgrade in place, app data untouched); otherwise it opens
|
||||||
|
the installed app and exits 0, so an old setup left in Downloads never replaces or downgrades an
|
||||||
|
install the updater has moved on. `/FORCE` reinstalls the same version (repair), `/NORUN` does
|
||||||
|
not open the app, `/UPDATE` is the updater's path and always installs. An app renamed after its
|
||||||
|
first release keeps its registry keys by defining `WAYBETTER_LEGACY_NAME` in its installer hooks
|
||||||
|
(`bundle.windows.nsis.installerHooks`).
|
||||||
|
|
||||||
## Consuming it
|
## Consuming it
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -661,6 +661,9 @@ function securityRs(o) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The framework's NSIS template, from the app's `src-tauri` folder (tauri.conf.json paths). */
|
||||||
|
const WINDOWS_INSTALLER = '../node_modules/waybetter/windows/installer.nsi';
|
||||||
|
|
||||||
/** @param {AppOptions} o */
|
/** @param {AppOptions} o */
|
||||||
function tauriConf(o) {
|
function tauriConf(o) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -686,6 +689,9 @@ function tauriConf(o) {
|
||||||
active: true,
|
active: true,
|
||||||
targets: 'all',
|
targets: 'all',
|
||||||
icon: ['icons/icon.png', 'icons/icon.ico'],
|
icon: ['icons/icon.png', 'icons/icon.ico'],
|
||||||
|
// Windows: the framework's installer (no wizard, per user; a setup run again opens the
|
||||||
|
// installed app instead of replacing or downgrading it). See waybetter/windows/installer.nsi.
|
||||||
|
windows: { nsis: { installMode: 'currentUser', template: WINDOWS_INSTALLER } },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -326,6 +326,11 @@ test('app: every site skeleton is consistent across its native and page halves',
|
||||||
assert.deepEqual(caps[2].remote.urls, JSON.parse(`[${tsHosts}]`).map(host => `https://${host}/*`));
|
assert.deepEqual(caps[2].remote.urls, JSON.parse(`[${tsHosts}]`).map(host => `https://${host}/*`));
|
||||||
assert.equal(caps[0].local, true);
|
assert.equal(caps[0].local, true);
|
||||||
assert.deepEqual(JSON.parse(file('src-tauri', 'tauri.conf.json')).app.security.capabilities.sort(), ['shell', 'site-tab', 'tab-chrome']);
|
assert.deepEqual(JSON.parse(file('src-tauri', 'tauri.conf.json')).app.security.capabilities.sort(), ['shell', 'site-tab', 'tab-chrome']);
|
||||||
|
// The Windows installer is the framework's template, a file the package ships.
|
||||||
|
const nsis = JSON.parse(file('src-tauri', 'tauri.conf.json')).bundle.windows.nsis;
|
||||||
|
assert.deepEqual(nsis, { installMode: 'currentUser', template: '../node_modules/waybetter/windows/installer.nsi' });
|
||||||
|
assert.ok(existsSync(join(PACKAGE, 'windows', 'installer.nsi')), 'the package has the installer template');
|
||||||
|
assert.ok(JSON.parse(readFileSync(join(PACKAGE, 'package.json'), 'utf8')).files.includes('windows'), 'and publishes it');
|
||||||
// Every `waybetter/...` import is a published subpath of the package.
|
// Every `waybetter/...` import is a published subpath of the package.
|
||||||
const sources = ['src/site.ts', 'src/address.ts', 'src/runtime/main.ts', 'src/shell/main.tsx', 'src/shell/Panel.tsx', 'scripts/build.mjs'].map(path => file(...path.split('/'))).join('\n');
|
const sources = ['src/site.ts', 'src/address.ts', 'src/runtime/main.ts', 'src/shell/main.tsx', 'src/shell/Panel.tsx', 'scripts/build.mjs'].map(path => file(...path.split('/'))).join('\n');
|
||||||
for (const [, specifier] of sources.matchAll(/from '(waybetter\/[^']+)'/g)) assert.ok(exported(specifier), `${specifier} is exported`);
|
for (const [, specifier] of sources.matchAll(/from '(waybetter\/[^']+)'/g)) assert.ok(exported(specifier), `${specifier} is exported`);
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ package's real API and schema; `--help` lists every option.
|
||||||
|
|
||||||
| Project | Target | What it is |
|
| Project | Target | What it is |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| [wayBetter for X](https://waybetter.fyi/twttr/) | x.com (website) | Desktop app around the live X: tabs, split panes, real accounts side by side, themes, plugins, drafts and fixes for X's own bugs. The first wayBetter app. |
|
| [wayBetter for X](https://waybetter.fyi/x/) | x.com (website) | Desktop app around the live X: tabs, split panes, real accounts side by side, themes, plugins, drafts and fixes for X's own bugs. The first wayBetter app. |
|
||||||
|
|
||||||
Built something on wayBetter? Add it to this list with a pull request: name and link, what it extends, one line on what it does.
|
Built something on wayBetter? Add it to this list with a pull request: name and link, what it extends, one line on what it does.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,7 @@
|
||||||
"i18n.schema.json",
|
"i18n.schema.json",
|
||||||
"i18n-meta.schema.json",
|
"i18n-meta.schema.json",
|
||||||
"locales",
|
"locales",
|
||||||
|
"windows",
|
||||||
"README.md",
|
"README.md",
|
||||||
"LICENSE"
|
"LICENSE"
|
||||||
],
|
],
|
||||||
|
|
|
||||||
897
packages/waybetter/windows/installer.nsi
Normal file
897
packages/waybetter/windows/installer.nsi
Normal file
|
|
@ -0,0 +1,897 @@
|
||||||
|
; wayBetter's Windows installer (NSIS), a template for Tauri's bundler: Tauri 2.12's default with
|
||||||
|
; every wizard page removed. Point `bundle.windows.nsis.template` in tauri.conf.json at this file.
|
||||||
|
;
|
||||||
|
; What running the setup does:
|
||||||
|
; - nothing installed (or the installed exe is gone): installs for the current user, no UAC and
|
||||||
|
; no wizard, makes the Desktop and Start menu shortcuts, opens the app;
|
||||||
|
; - the same or a newer version is installed: installs nothing, opens the installed app (its
|
||||||
|
; single-instance guard shows the running window) and exits 0. So an old setup left in
|
||||||
|
; Downloads can never replace, restart or downgrade an install the updater has moved on;
|
||||||
|
; - an older version is installed: upgrades in place (app data untouched), then opens the app.
|
||||||
|
; Flags: `/NORUN` never opens the app, `/FORCE` reinstalls the same version (repair; it still never
|
||||||
|
; downgrades), `/UPDATE` is the updater's path (tauri-plugin-updater: `/UPDATE /R /ARGS ...`),
|
||||||
|
; which always installs and is otherwise Tauri's. `/NS` (no shortcuts) and `/D=<folder>` as in Tauri.
|
||||||
|
;
|
||||||
|
; An app that shipped under another name keeps its registry keys (one Apps & Features entry, the
|
||||||
|
; remembered install folder) by defining the old name in its installer hooks
|
||||||
|
; (`bundle.windows.nsis.installerHooks`), which are included before anything here reads it:
|
||||||
|
; !define WAYBETTER_LEGACY_NAME "Old Product Name"
|
||||||
|
; !define WAYBETTER_LEGACY_MANUFACTURER "Old Publisher" ; optional, defaults to the old name
|
||||||
|
Unicode true
|
||||||
|
ManifestDPIAware true
|
||||||
|
; wayBetter: never show a wizard.
|
||||||
|
SilentInstall silent
|
||||||
|
; Add in `dpiAwareness` `PerMonitorV2` to manifest for Windows 10 1607+ (note this should not affect lower versions since they should be able to ignore this and pick up `dpiAware` `true` set by `ManifestDPIAware true`)
|
||||||
|
; Currently undocumented on NSIS's website but is in the Docs folder of source tree, see
|
||||||
|
; https://github.com/kichik/nsis/blob/5fc0b87b819a9eec006df4967d08e522ddd651c9/Docs/src/attributes.but#L286-L300
|
||||||
|
; https://github.com/tauri-apps/tauri/pull/10106
|
||||||
|
ManifestDPIAwareness PerMonitorV2
|
||||||
|
|
||||||
|
!if "{{compression}}" == "none"
|
||||||
|
SetCompress off
|
||||||
|
!else
|
||||||
|
; Set the compression algorithm. We default to LZMA.
|
||||||
|
SetCompressor /SOLID "{{compression}}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Keep above !include to stay ahead of any plugin command
|
||||||
|
; see https://github.com/tauri-apps/tauri/pull/15422#discussion_r3289239624
|
||||||
|
{{#if signed_plugins_path}}
|
||||||
|
!addplugindir "{{signed_plugins_path}}"
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
!include MUI2.nsh
|
||||||
|
!include FileFunc.nsh
|
||||||
|
!include x64.nsh
|
||||||
|
!include WordFunc.nsh
|
||||||
|
!include "utils.nsh"
|
||||||
|
!include "FileAssociation.nsh"
|
||||||
|
!include "Win\COM.nsh"
|
||||||
|
!include "Win\Propkey.nsh"
|
||||||
|
!include "Win\RestartManager.nsh"
|
||||||
|
!include "StrFunc.nsh"
|
||||||
|
${StrCase}
|
||||||
|
${StrLoc}
|
||||||
|
|
||||||
|
{{#if installer_hooks}}
|
||||||
|
!include "{{installer_hooks}}"
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
!define WEBVIEW2APPGUID "{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"
|
||||||
|
|
||||||
|
!define MANUFACTURER "{{manufacturer}}"
|
||||||
|
!define PRODUCTNAME "{{product_name}}"
|
||||||
|
!define VERSION "{{version}}"
|
||||||
|
!define VERSIONWITHBUILD "{{version_with_build}}"
|
||||||
|
!define HOMEPAGE "{{homepage}}"
|
||||||
|
!define INSTALLMODE "{{install_mode}}"
|
||||||
|
!define LICENSE "{{license}}"
|
||||||
|
!define INSTALLERICON "{{installer_icon}}"
|
||||||
|
!define SIDEBARIMAGE "{{sidebar_image}}"
|
||||||
|
!define HEADERIMAGE "{{header_image}}"
|
||||||
|
!define UNINSTALLERICON "{{uninstaller_icon}}"
|
||||||
|
!define UNINSTALLERHEADERIMAGE "{{uninstaller_header_image}}"
|
||||||
|
!define MAINBINARYNAME "{{main_binary_name}}"
|
||||||
|
!define MAINBINARYSRCPATH "{{main_binary_path}}"
|
||||||
|
!define BUNDLEID "{{bundle_id}}"
|
||||||
|
!define COPYRIGHT "{{copyright}}"
|
||||||
|
!define OUTFILE "{{out_file}}"
|
||||||
|
!define ARCH "{{arch}}"
|
||||||
|
!define ADDITIONALPLUGINSPATH "{{additional_plugins_path}}"
|
||||||
|
!define ALLOWDOWNGRADES "{{allow_downgrades}}"
|
||||||
|
!define DISPLAYLANGUAGESELECTOR "{{display_language_selector}}"
|
||||||
|
!define INSTALLWEBVIEW2MODE "{{install_webview2_mode}}"
|
||||||
|
!define WEBVIEW2INSTALLERARGS "{{webview2_installer_args}}"
|
||||||
|
!define WEBVIEW2BOOTSTRAPPERPATH "{{webview2_bootstrapper_path}}"
|
||||||
|
!define WEBVIEW2INSTALLERPATH "{{webview2_installer_path}}"
|
||||||
|
!define MINIMUMWEBVIEW2VERSION "{{minimum_webview2_version}}"
|
||||||
|
; wayBetter: an app renamed after its first release defines WAYBETTER_LEGACY_NAME (see the top of
|
||||||
|
; this file). Its registry keys keep the old name for good, like the bundle identifier: the updater
|
||||||
|
; runs this installer with /UPDATE, RestorePreviousInstallLocation reads the install folder from
|
||||||
|
; MANUPRODUCTKEY, and Apps & Features must keep a single entry. The key names are never shown;
|
||||||
|
; DisplayName, Publisher, shortcuts and dialogs use ${PRODUCTNAME} / ${MANUFACTURER}.
|
||||||
|
!ifdef WAYBETTER_LEGACY_NAME
|
||||||
|
!define LEGACYNAME "${WAYBETTER_LEGACY_NAME}"
|
||||||
|
!define /ifndef WAYBETTER_LEGACY_MANUFACTURER "${WAYBETTER_LEGACY_NAME}"
|
||||||
|
!define UNINSTKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${LEGACYNAME}"
|
||||||
|
!define MANUKEY "Software\${WAYBETTER_LEGACY_MANUFACTURER}"
|
||||||
|
!define MANUPRODUCTKEY "${MANUKEY}\${LEGACYNAME}"
|
||||||
|
!else
|
||||||
|
!define UNINSTKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCTNAME}"
|
||||||
|
!define MANUKEY "Software\${MANUFACTURER}"
|
||||||
|
!define MANUPRODUCTKEY "${MANUKEY}\${PRODUCTNAME}"
|
||||||
|
!endif
|
||||||
|
!define UNINSTALLERSIGNCOMMAND "{{uninstaller_sign_cmd}}"
|
||||||
|
!define ESTIMATEDSIZE "{{estimated_size}}"
|
||||||
|
!define STARTMENUFOLDER "{{start_menu_folder}}"
|
||||||
|
|
||||||
|
Var PassiveMode
|
||||||
|
Var UpdateMode
|
||||||
|
Var ForceMode
|
||||||
|
Var NoShortcutMode
|
||||||
|
Var WixMode
|
||||||
|
Var OldMainBinaryName
|
||||||
|
|
||||||
|
Name "${PRODUCTNAME}"
|
||||||
|
BrandingText "${COPYRIGHT}"
|
||||||
|
OutFile "${OUTFILE}"
|
||||||
|
|
||||||
|
; We don't actually use this value as default install path,
|
||||||
|
; it's just for nsis to append the product name folder in the directory selector
|
||||||
|
; https://nsis.sourceforge.io/Reference/InstallDir
|
||||||
|
!define PLACEHOLDER_INSTALL_DIR "placeholder\${PRODUCTNAME}"
|
||||||
|
InstallDir "${PLACEHOLDER_INSTALL_DIR}"
|
||||||
|
|
||||||
|
VIProductVersion "${VERSIONWITHBUILD}"
|
||||||
|
VIAddVersionKey "ProductName" "${PRODUCTNAME}"
|
||||||
|
VIAddVersionKey "FileDescription" "${PRODUCTNAME}"
|
||||||
|
VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
|
||||||
|
VIAddVersionKey "FileVersion" "${VERSION}"
|
||||||
|
VIAddVersionKey "ProductVersion" "${VERSION}"
|
||||||
|
|
||||||
|
# additional plugins
|
||||||
|
!addplugindir "${ADDITIONALPLUGINSPATH}"
|
||||||
|
|
||||||
|
; Uninstaller signing command
|
||||||
|
!if "${UNINSTALLERSIGNCOMMAND}" != ""
|
||||||
|
!uninstfinalize '${UNINSTALLERSIGNCOMMAND}'
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Handle install mode, `perUser`, `perMachine` or `both`
|
||||||
|
!if "${INSTALLMODE}" == "perMachine"
|
||||||
|
RequestExecutionLevel admin
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!if "${INSTALLMODE}" == "currentUser"
|
||||||
|
RequestExecutionLevel user
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!if "${INSTALLMODE}" == "both"
|
||||||
|
!define MULTIUSER_MUI
|
||||||
|
!define MULTIUSER_INSTALLMODE_INSTDIR "${PRODUCTNAME}"
|
||||||
|
!define MULTIUSER_INSTALLMODE_COMMANDLINE
|
||||||
|
!if "${ARCH}" == "x64"
|
||||||
|
!define MULTIUSER_USE_PROGRAMFILES64
|
||||||
|
!else if "${ARCH}" == "arm64"
|
||||||
|
!define MULTIUSER_USE_PROGRAMFILES64
|
||||||
|
!endif
|
||||||
|
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${UNINSTKEY}"
|
||||||
|
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "CurrentUser"
|
||||||
|
!define MULTIUSER_INSTALLMODEPAGE_SHOWUSERNAME
|
||||||
|
!define MULTIUSER_INSTALLMODE_FUNCTION RestorePreviousInstallLocation
|
||||||
|
!define MULTIUSER_EXECUTIONLEVEL Highest
|
||||||
|
!include MultiUser.nsh
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Installer icon
|
||||||
|
!if "${INSTALLERICON}" != ""
|
||||||
|
!define MUI_ICON "${INSTALLERICON}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Installer sidebar image
|
||||||
|
!if "${SIDEBARIMAGE}" != ""
|
||||||
|
!define MUI_WELCOMEFINISHPAGE_BITMAP "${SIDEBARIMAGE}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Enable header images for installer and uninstaller pages when either image is configured.
|
||||||
|
!if "${HEADERIMAGE}" != ""
|
||||||
|
!define MUI_HEADERIMAGE
|
||||||
|
!else if "${UNINSTALLERHEADERIMAGE}" != ""
|
||||||
|
!define MUI_HEADERIMAGE
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Installer header image
|
||||||
|
!if "${HEADERIMAGE}" != ""
|
||||||
|
!define MUI_HEADERIMAGE_BITMAP "${HEADERIMAGE}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Uninstaller header image
|
||||||
|
!if "${UNINSTALLERHEADERIMAGE}" != ""
|
||||||
|
!define MUI_HEADERIMAGE_UNBITMAP "${UNINSTALLERHEADERIMAGE}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Uninstaller icon
|
||||||
|
!if "${UNINSTALLERICON}" != ""
|
||||||
|
!define MUI_UNICON "${UNINSTALLERICON}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Define registry key to store installer language
|
||||||
|
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
|
||||||
|
!define MUI_LANGDLL_REGISTRY_KEY "${MANUPRODUCTKEY}"
|
||||||
|
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
|
||||||
|
|
||||||
|
; wayBetter: no wizard. Every installer page is removed and the installer always runs
|
||||||
|
; silently (per-user, no UAC). A first install launches the app when it finishes; the updater's
|
||||||
|
; `/UPDATE /R /ARGS ...` path below is unchanged, so tauri-plugin-updater keeps working.
|
||||||
|
; Only the start-menu page is declared, always skipped, because MUI_STARTMENU_WRITE_* needs it.
|
||||||
|
Var AppStartMenuFolder
|
||||||
|
!if "${STARTMENUFOLDER}" != ""
|
||||||
|
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "${STARTMENUFOLDER}"
|
||||||
|
!endif
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_PRE Skip
|
||||||
|
!insertmacro MUI_PAGE_STARTMENU Application $AppStartMenuFolder
|
||||||
|
|
||||||
|
; Progress page: never shown because the installer is silent.
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfPassive
|
||||||
|
!insertmacro MUI_PAGE_INSTFILES
|
||||||
|
|
||||||
|
|
||||||
|
; Uninstaller Pages
|
||||||
|
; 1. Confirm uninstall page
|
||||||
|
Var DeleteAppDataCheckbox
|
||||||
|
Var DeleteAppDataCheckboxState
|
||||||
|
!define /ifndef WS_EX_LAYOUTRTL 0x00400000
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ConfirmShow
|
||||||
|
Function un.ConfirmShow ; Add add a `Delete app data` check box
|
||||||
|
; $1 inner dialog HWND
|
||||||
|
; $2 window DPI
|
||||||
|
; $3 style
|
||||||
|
; $4 x
|
||||||
|
; $5 y
|
||||||
|
; $6 width
|
||||||
|
; $7 height
|
||||||
|
FindWindow $1 "#32770" "" $HWNDPARENT ; Find inner dialog
|
||||||
|
System::Call "user32::GetDpiForWindow(p r1) i .r2"
|
||||||
|
${If} $(^RTL) = 1
|
||||||
|
StrCpy $3 "${__NSD_CheckBox_EXSTYLE} | ${WS_EX_LAYOUTRTL}"
|
||||||
|
IntOp $4 50 * $2
|
||||||
|
${Else}
|
||||||
|
StrCpy $3 "${__NSD_CheckBox_EXSTYLE}"
|
||||||
|
IntOp $4 0 * $2
|
||||||
|
${EndIf}
|
||||||
|
IntOp $5 100 * $2
|
||||||
|
IntOp $6 400 * $2
|
||||||
|
IntOp $7 25 * $2
|
||||||
|
IntOp $4 $4 / 96
|
||||||
|
IntOp $5 $5 / 96
|
||||||
|
IntOp $6 $6 / 96
|
||||||
|
IntOp $7 $7 / 96
|
||||||
|
System::Call 'user32::CreateWindowEx(i r3, w "${__NSD_CheckBox_CLASS}", w "$(deleteAppData)", i ${__NSD_CheckBox_STYLE}, i r4, i r5, i r6, i r7, p r1, i0, i0, i0) i .s'
|
||||||
|
Pop $DeleteAppDataCheckbox
|
||||||
|
SendMessage $HWNDPARENT ${WM_GETFONT} 0 0 $1
|
||||||
|
SendMessage $DeleteAppDataCheckbox ${WM_SETFONT} $1 1
|
||||||
|
FunctionEnd
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.ConfirmLeave
|
||||||
|
Function un.ConfirmLeave
|
||||||
|
SendMessage $DeleteAppDataCheckbox ${BM_GETCHECK} 0 0 $DeleteAppDataCheckboxState
|
||||||
|
FunctionEnd
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_PRE un.SkipIfPassive
|
||||||
|
!insertmacro MUI_UNPAGE_CONFIRM
|
||||||
|
|
||||||
|
; 2. Uninstalling Page
|
||||||
|
!insertmacro MUI_UNPAGE_INSTFILES
|
||||||
|
|
||||||
|
;Languages
|
||||||
|
{{#each languages}}
|
||||||
|
!insertmacro MUI_LANGUAGE "{{this}}"
|
||||||
|
{{/each}}
|
||||||
|
!insertmacro MUI_RESERVEFILE_LANGDLL
|
||||||
|
{{#each language_files}}
|
||||||
|
!include "{{this}}"
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
Function .onInit
|
||||||
|
${GetOptions} $CMDLINE "/P" $PassiveMode
|
||||||
|
${IfNot} ${Errors}
|
||||||
|
StrCpy $PassiveMode 1
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
${GetOptions} $CMDLINE "/NS" $NoShortcutMode
|
||||||
|
${IfNot} ${Errors}
|
||||||
|
StrCpy $NoShortcutMode 1
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
${GetOptions} $CMDLINE "/UPDATE" $UpdateMode
|
||||||
|
${IfNot} ${Errors}
|
||||||
|
StrCpy $UpdateMode 1
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
${GetOptions} $CMDLINE "/FORCE" $ForceMode
|
||||||
|
${IfNot} ${Errors}
|
||||||
|
StrCpy $ForceMode 1
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
!if "${DISPLAYLANGUAGESELECTOR}" == "true"
|
||||||
|
!insertmacro MUI_LANGDLL_DISPLAY
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!insertmacro SetContext
|
||||||
|
|
||||||
|
${If} $INSTDIR == "${PLACEHOLDER_INSTALL_DIR}"
|
||||||
|
; Set default install location
|
||||||
|
!if "${INSTALLMODE}" == "perMachine"
|
||||||
|
${If} ${RunningX64}
|
||||||
|
!if "${ARCH}" == "x64"
|
||||||
|
StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCTNAME}"
|
||||||
|
!else if "${ARCH}" == "arm64"
|
||||||
|
StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCTNAME}"
|
||||||
|
!else
|
||||||
|
StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCTNAME}"
|
||||||
|
!endif
|
||||||
|
${Else}
|
||||||
|
StrCpy $INSTDIR "$PROGRAMFILES\${PRODUCTNAME}"
|
||||||
|
${EndIf}
|
||||||
|
!else if "${INSTALLMODE}" == "currentUser"
|
||||||
|
StrCpy $INSTDIR "$LOCALAPPDATA\${PRODUCTNAME}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
Call RestorePreviousInstallLocation
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
|
||||||
|
!if "${INSTALLMODE}" == "both"
|
||||||
|
!insertmacro MULTIUSER_INIT
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; wayBetter: a setup run by hand (not the updater) opens an install that is already current
|
||||||
|
; instead of replacing it.
|
||||||
|
${If} $UpdateMode <> 1
|
||||||
|
Call OpenInstalledIfCurrent
|
||||||
|
${EndIf}
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
; wayBetter: when the app is installed in $INSTDIR at this setup's version or a newer one, open it
|
||||||
|
; and quit with exit code 0: nothing is copied, no running app is closed, nothing is downgraded.
|
||||||
|
; Returns (and the install goes ahead) when nothing is installed, when the registry names an install
|
||||||
|
; whose exe is gone, when the installed version is older, or on /FORCE with the same version.
|
||||||
|
Function OpenInstalledIfCurrent
|
||||||
|
; $R1 the installed exe's name, $R2 the installed version, $R3 this setup compared to it
|
||||||
|
ReadRegStr $R1 SHCTX "${UNINSTKEY}" "MainBinaryName"
|
||||||
|
${If} $R1 == ""
|
||||||
|
StrCpy $R1 "${MAINBINARYNAME}.exe"
|
||||||
|
${EndIf}
|
||||||
|
${IfNot} ${FileExists} "$INSTDIR\$R1"
|
||||||
|
Return
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
ReadRegStr $R2 SHCTX "${UNINSTKEY}" "DisplayVersion"
|
||||||
|
${If} $R2 == ""
|
||||||
|
; No version in the registry: the exe's own file version, a.b.c.d -> a.b.c
|
||||||
|
ClearErrors
|
||||||
|
${GetFileVersion} "$INSTDIR\$R1" $R2
|
||||||
|
${If} ${Errors}
|
||||||
|
${OrIf} $R2 == ""
|
||||||
|
Return
|
||||||
|
${EndIf}
|
||||||
|
${WordFind} $R2 "." "+1" $R3
|
||||||
|
${WordFind} $R2 "." "+2" $R4
|
||||||
|
${WordFind} $R2 "." "+3" $R5
|
||||||
|
StrCpy $R2 "$R3.$R4.$R5"
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; 1: this setup is newer, 0: the same version, -1: this setup is older
|
||||||
|
nsis_tauri_utils::SemverCompare "${VERSION}" $R2
|
||||||
|
Pop $R3
|
||||||
|
${If} $R3 = 1
|
||||||
|
Return
|
||||||
|
${EndIf}
|
||||||
|
${If} $R3 = 0
|
||||||
|
${AndIf} $ForceMode = 1
|
||||||
|
Return
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
${GetOptions} $CMDLINE "/NORUN" $R0
|
||||||
|
${If} ${Errors}
|
||||||
|
; Hand over this setup's right to take the foreground (ASFW_ANY), so the running app's window
|
||||||
|
; can come to the front when its single-instance guard hears about the second launch.
|
||||||
|
System::Call 'user32::AllowSetForegroundWindow(i -1)'
|
||||||
|
nsis_tauri_utils::RunAsUser "$INSTDIR\$R1" ""
|
||||||
|
${EndIf}
|
||||||
|
SetErrorLevel 0
|
||||||
|
Quit
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
|
||||||
|
Section EarlyChecks
|
||||||
|
; Abort silent installer if downgrades is disabled
|
||||||
|
!if "${ALLOWDOWNGRADES}" == "false"
|
||||||
|
${If} ${Silent}
|
||||||
|
; If downgrading (wayBetter: there is no reinstall page to compare the versions, so here)
|
||||||
|
StrCpy $R0 0
|
||||||
|
ReadRegStr $R2 SHCTX "${UNINSTKEY}" "DisplayVersion"
|
||||||
|
${If} $R2 != ""
|
||||||
|
nsis_tauri_utils::SemverCompare "${VERSION}" $R2
|
||||||
|
Pop $R0
|
||||||
|
${EndIf}
|
||||||
|
${If} $R0 = -1
|
||||||
|
System::Call 'kernel32::AttachConsole(i -1)i.r0'
|
||||||
|
${If} $0 <> 0
|
||||||
|
System::Call 'kernel32::GetStdHandle(i -11)i.r0'
|
||||||
|
System::call 'kernel32::SetConsoleTextAttribute(i r0, i 0x0004)' ; set red color
|
||||||
|
FileWrite $0 "$(silentDowngrades)"
|
||||||
|
${EndIf}
|
||||||
|
Abort
|
||||||
|
${EndIf}
|
||||||
|
${EndIf}
|
||||||
|
!endif
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section WebView2
|
||||||
|
; Check if Webview2 is already installed and skip this section
|
||||||
|
${If} ${RunningX64}
|
||||||
|
ReadRegStr $4 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\${WEBVIEW2APPGUID}" "pv"
|
||||||
|
${Else}
|
||||||
|
ReadRegStr $4 HKLM "SOFTWARE\Microsoft\EdgeUpdate\Clients\${WEBVIEW2APPGUID}" "pv"
|
||||||
|
${EndIf}
|
||||||
|
${If} $4 == ""
|
||||||
|
ReadRegStr $4 HKCU "SOFTWARE\Microsoft\EdgeUpdate\Clients\${WEBVIEW2APPGUID}" "pv"
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
${If} $4 == ""
|
||||||
|
; Webview2 installation
|
||||||
|
;
|
||||||
|
; Skip if updating
|
||||||
|
${If} $UpdateMode <> 1
|
||||||
|
!if "${INSTALLWEBVIEW2MODE}" == "downloadBootstrapper"
|
||||||
|
Delete "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||||
|
DetailPrint "$(webview2Downloading)"
|
||||||
|
NSISdl::download "https://go.microsoft.com/fwlink/p/?LinkId=2124703" "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||||
|
Pop $0
|
||||||
|
${If} $0 == "success"
|
||||||
|
DetailPrint "$(webview2DownloadSuccess)"
|
||||||
|
${Else}
|
||||||
|
DetailPrint "$(webview2DownloadError)"
|
||||||
|
Abort "$(webview2AbortError)"
|
||||||
|
${EndIf}
|
||||||
|
StrCpy $6 "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||||
|
Goto install_webview2
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!if "${INSTALLWEBVIEW2MODE}" == "embedBootstrapper"
|
||||||
|
Delete "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||||
|
File "/oname=$TEMP\MicrosoftEdgeWebview2Setup.exe" "${WEBVIEW2BOOTSTRAPPERPATH}"
|
||||||
|
DetailPrint "$(installingWebview2)"
|
||||||
|
StrCpy $6 "$TEMP\MicrosoftEdgeWebview2Setup.exe"
|
||||||
|
Goto install_webview2
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!if "${INSTALLWEBVIEW2MODE}" == "offlineInstaller"
|
||||||
|
Delete "$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe"
|
||||||
|
File "/oname=$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe" "${WEBVIEW2INSTALLERPATH}"
|
||||||
|
DetailPrint "$(installingWebview2)"
|
||||||
|
StrCpy $6 "$TEMP\MicrosoftEdgeWebView2RuntimeInstaller.exe"
|
||||||
|
Goto install_webview2
|
||||||
|
!endif
|
||||||
|
|
||||||
|
Goto webview2_done
|
||||||
|
|
||||||
|
install_webview2:
|
||||||
|
DetailPrint "$(installingWebview2)"
|
||||||
|
; $6 holds the path to the webview2 installer
|
||||||
|
ExecWait "$6 ${WEBVIEW2INSTALLERARGS} /install" $1
|
||||||
|
${If} $1 = 0
|
||||||
|
DetailPrint "$(webview2InstallSuccess)"
|
||||||
|
${Else}
|
||||||
|
DetailPrint "$(webview2InstallError)"
|
||||||
|
Abort "$(webview2AbortError)"
|
||||||
|
${EndIf}
|
||||||
|
webview2_done:
|
||||||
|
${EndIf}
|
||||||
|
${Else}
|
||||||
|
!if "${MINIMUMWEBVIEW2VERSION}" != ""
|
||||||
|
${VersionCompare} "${MINIMUMWEBVIEW2VERSION}" "$4" $R0
|
||||||
|
${If} $R0 = 1
|
||||||
|
update_webview:
|
||||||
|
DetailPrint "$(installingWebview2)"
|
||||||
|
${If} ${RunningX64}
|
||||||
|
ReadRegStr $R1 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate" "path"
|
||||||
|
${Else}
|
||||||
|
ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\EdgeUpdate" "path"
|
||||||
|
${EndIf}
|
||||||
|
${If} $R1 == ""
|
||||||
|
ReadRegStr $R1 HKCU "SOFTWARE\Microsoft\EdgeUpdate" "path"
|
||||||
|
${EndIf}
|
||||||
|
${If} $R1 != ""
|
||||||
|
; Chromium updater docs: https://source.chromium.org/chromium/chromium/src/+/main:docs/updater/user_manual.md
|
||||||
|
; Modified from "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView\ModifyPath"
|
||||||
|
ExecWait `"$R1" /install appguid=${WEBVIEW2APPGUID}&needsadmin=true` $1
|
||||||
|
${If} $1 = 0
|
||||||
|
DetailPrint "$(webview2InstallSuccess)"
|
||||||
|
${Else}
|
||||||
|
MessageBox MB_ICONEXCLAMATION|MB_ABORTRETRYIGNORE "$(webview2InstallError)" IDIGNORE ignore IDRETRY update_webview
|
||||||
|
Quit
|
||||||
|
ignore:
|
||||||
|
${EndIf}
|
||||||
|
${EndIf}
|
||||||
|
${EndIf}
|
||||||
|
!endif
|
||||||
|
${EndIf}
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section Install
|
||||||
|
SetOutPath $INSTDIR
|
||||||
|
|
||||||
|
!ifmacrodef NSIS_HOOK_PREINSTALL
|
||||||
|
!insertmacro NSIS_HOOK_PREINSTALL
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!insertmacro CheckIfAppIsRunning "$INSTDIR\${MAINBINARYNAME}.exe" "${PRODUCTNAME}"
|
||||||
|
|
||||||
|
; Copy main executable
|
||||||
|
File "${MAINBINARYSRCPATH}"
|
||||||
|
|
||||||
|
; Copy resources
|
||||||
|
{{#each resources_dirs}}
|
||||||
|
CreateDirectory "$INSTDIR\\{{this}}"
|
||||||
|
{{/each}}
|
||||||
|
{{#each resources}}
|
||||||
|
File /a "/oname={{this.[1]}}" "{{no-escape @key}}"
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
; Copy external binaries
|
||||||
|
{{#each binaries}}
|
||||||
|
File /a "/oname={{this}}" "{{no-escape @key}}"
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
; Create file associations
|
||||||
|
{{#each file_associations as |association| ~}}
|
||||||
|
{{#each association.ext as |ext| ~}}
|
||||||
|
!insertmacro APP_ASSOCIATE "{{ext}}" "{{or association.name ext}}" "{{association-description association.description ext}}" "$INSTDIR\${MAINBINARYNAME}.exe,0" "Open with ${PRODUCTNAME}" "$INSTDIR\${MAINBINARYNAME}.exe $\"%1$\""
|
||||||
|
{{/each}}
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
; Register deep links
|
||||||
|
{{#each deep_link_protocols as |protocol| ~}}
|
||||||
|
WriteRegStr SHCTX "Software\Classes\\{{protocol}}" "URL Protocol" ""
|
||||||
|
WriteRegStr SHCTX "Software\Classes\\{{protocol}}" "" "URL:${BUNDLEID} protocol"
|
||||||
|
WriteRegStr SHCTX "Software\Classes\\{{protocol}}\DefaultIcon" "" "$\"$INSTDIR\${MAINBINARYNAME}.exe$\",0"
|
||||||
|
WriteRegStr SHCTX "Software\Classes\\{{protocol}}\shell\open\command" "" "$\"$INSTDIR\${MAINBINARYNAME}.exe$\" $\"%1$\""
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
; Create uninstaller
|
||||||
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||||
|
|
||||||
|
; Save $INSTDIR in registry for future installations
|
||||||
|
WriteRegStr SHCTX "${MANUPRODUCTKEY}" "" $INSTDIR
|
||||||
|
|
||||||
|
!if "${INSTALLMODE}" == "both"
|
||||||
|
; Save install mode to be selected by default for the next installation such as updating
|
||||||
|
; or when uninstalling
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" $MultiUser.InstallMode 1
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Remove old main binary if it doesn't match new main binary name
|
||||||
|
ReadRegStr $OldMainBinaryName SHCTX "${UNINSTKEY}" "MainBinaryName"
|
||||||
|
${If} $OldMainBinaryName != ""
|
||||||
|
${AndIf} $OldMainBinaryName != "${MAINBINARYNAME}.exe"
|
||||||
|
Delete "$INSTDIR\$OldMainBinaryName"
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; Save current MAINBINARYNAME for future updates
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "MainBinaryName" "${MAINBINARYNAME}.exe"
|
||||||
|
|
||||||
|
; Registry information for add/remove programs
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayName" "${PRODUCTNAME}"
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayIcon" "$\"$INSTDIR\${MAINBINARYNAME}.exe$\""
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "DisplayVersion" "${VERSION}"
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "Publisher" "${MANUFACTURER}"
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "InstallLocation" "$\"$INSTDIR$\""
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
|
||||||
|
WriteRegDWORD SHCTX "${UNINSTKEY}" "NoModify" "1"
|
||||||
|
WriteRegDWORD SHCTX "${UNINSTKEY}" "NoRepair" "1"
|
||||||
|
|
||||||
|
${GetSize} "$INSTDIR" "/M=uninstall.exe /S=0K /G=0" $0 $1 $2
|
||||||
|
IntOp $0 $0 + ${ESTIMATEDSIZE}
|
||||||
|
IntFmt $0 "0x%08X" $0
|
||||||
|
WriteRegDWORD SHCTX "${UNINSTKEY}" "EstimatedSize" "$0"
|
||||||
|
|
||||||
|
!if "${HOMEPAGE}" != ""
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "URLInfoAbout" "${HOMEPAGE}"
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "URLUpdateInfo" "${HOMEPAGE}"
|
||||||
|
WriteRegStr SHCTX "${UNINSTKEY}" "HelpLink" "${HOMEPAGE}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Create start menu shortcut
|
||||||
|
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
||||||
|
Call CreateOrUpdateStartMenuShortcut
|
||||||
|
!insertmacro MUI_STARTMENU_WRITE_END
|
||||||
|
|
||||||
|
; Create desktop shortcut for silent and passive installers
|
||||||
|
; because finish page will be skipped
|
||||||
|
${If} $PassiveMode = 1
|
||||||
|
${OrIf} ${Silent}
|
||||||
|
Call CreateOrUpdateDesktopShortcut
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
!ifmacrodef NSIS_HOOK_POSTINSTALL
|
||||||
|
!insertmacro NSIS_HOOK_POSTINSTALL
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Auto close this page for passive mode
|
||||||
|
${If} $PassiveMode = 1
|
||||||
|
SetAutoClose true
|
||||||
|
${EndIf}
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Function .onInstSuccess
|
||||||
|
; Check for `/R` flag only in silent and passive installers because
|
||||||
|
; GUI installer has a toggle for the user to (re)start the app
|
||||||
|
${If} $PassiveMode = 1
|
||||||
|
${OrIf} ${Silent}
|
||||||
|
${GetOptions} $CMDLINE "/R" $R0
|
||||||
|
${IfNot} ${Errors}
|
||||||
|
${GetOptions} $CMDLINE "/ARGS" $R0
|
||||||
|
nsis_tauri_utils::RunAsUser "$INSTDIR\${MAINBINARYNAME}.exe" "$R0"
|
||||||
|
Return
|
||||||
|
${EndIf}
|
||||||
|
${EndIf}
|
||||||
|
; wayBetter: a first install (not an update) opens the app, unless `/NORUN` is passed.
|
||||||
|
${If} $UpdateMode <> 1
|
||||||
|
${GetOptions} $CMDLINE "/NORUN" $R0
|
||||||
|
${If} ${Errors}
|
||||||
|
nsis_tauri_utils::RunAsUser "$INSTDIR\${MAINBINARYNAME}.exe" ""
|
||||||
|
${EndIf}
|
||||||
|
${EndIf}
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Function un.onInit
|
||||||
|
!insertmacro SetContext
|
||||||
|
|
||||||
|
!if "${INSTALLMODE}" == "both"
|
||||||
|
!insertmacro MULTIUSER_UNINIT
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!insertmacro MUI_UNGETLANGUAGE
|
||||||
|
|
||||||
|
${GetOptions} $CMDLINE "/P" $PassiveMode
|
||||||
|
${IfNot} ${Errors}
|
||||||
|
StrCpy $PassiveMode 1
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
${GetOptions} $CMDLINE "/UPDATE" $UpdateMode
|
||||||
|
${IfNot} ${Errors}
|
||||||
|
StrCpy $UpdateMode 1
|
||||||
|
${EndIf}
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Section Uninstall
|
||||||
|
|
||||||
|
!ifmacrodef NSIS_HOOK_PREUNINSTALL
|
||||||
|
!insertmacro NSIS_HOOK_PREUNINSTALL
|
||||||
|
!endif
|
||||||
|
|
||||||
|
!insertmacro CheckIfAppIsRunning "$INSTDIR\${MAINBINARYNAME}.exe" "${PRODUCTNAME}"
|
||||||
|
|
||||||
|
; Delete the app directory and its content from disk
|
||||||
|
; Copy main executable
|
||||||
|
Delete "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
|
||||||
|
; Delete resources
|
||||||
|
{{#each resources}}
|
||||||
|
Delete "$INSTDIR\\{{this.[1]}}"
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
; Delete external binaries
|
||||||
|
{{#each binaries}}
|
||||||
|
Delete "$INSTDIR\\{{this}}"
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
; Delete app associations
|
||||||
|
{{#each file_associations as |association| ~}}
|
||||||
|
{{#each association.ext as |ext| ~}}
|
||||||
|
!insertmacro APP_UNASSOCIATE "{{ext}}" "{{or association.name ext}}"
|
||||||
|
{{/each}}
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
; Delete deep links
|
||||||
|
{{#each deep_link_protocols as |protocol| ~}}
|
||||||
|
ReadRegStr $R7 SHCTX "Software\Classes\\{{protocol}}\shell\open\command" ""
|
||||||
|
${If} $R7 == "$\"$INSTDIR\${MAINBINARYNAME}.exe$\" $\"%1$\""
|
||||||
|
DeleteRegKey SHCTX "Software\Classes\\{{protocol}}"
|
||||||
|
${EndIf}
|
||||||
|
{{/each}}
|
||||||
|
|
||||||
|
|
||||||
|
; Delete uninstaller
|
||||||
|
Delete "$INSTDIR\uninstall.exe"
|
||||||
|
|
||||||
|
{{#each resources_ancestors}}
|
||||||
|
RMDir /REBOOTOK "$INSTDIR\\{{this}}"
|
||||||
|
{{/each}}
|
||||||
|
RMDir "$INSTDIR"
|
||||||
|
|
||||||
|
; Remove shortcuts if not updating
|
||||||
|
${If} $UpdateMode <> 1
|
||||||
|
!insertmacro DeleteAppUserModelId
|
||||||
|
|
||||||
|
; Remove start menu shortcut
|
||||||
|
!insertmacro MUI_STARTMENU_GETFOLDER Application $AppStartMenuFolder
|
||||||
|
!insertmacro IsShortcutTarget "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
Pop $0
|
||||||
|
${If} $0 = 1
|
||||||
|
!insertmacro UnpinShortcut "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk"
|
||||||
|
Delete "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk"
|
||||||
|
RMDir "$SMPROGRAMS\$AppStartMenuFolder"
|
||||||
|
${EndIf}
|
||||||
|
!insertmacro IsShortcutTarget "$SMPROGRAMS\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
Pop $0
|
||||||
|
${If} $0 = 1
|
||||||
|
!insertmacro UnpinShortcut "$SMPROGRAMS\${PRODUCTNAME}.lnk"
|
||||||
|
Delete "$SMPROGRAMS\${PRODUCTNAME}.lnk"
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; Remove desktop shortcuts
|
||||||
|
!insertmacro IsShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
Pop $0
|
||||||
|
${If} $0 = 1
|
||||||
|
!insertmacro UnpinShortcut "$DESKTOP\${PRODUCTNAME}.lnk"
|
||||||
|
Delete "$DESKTOP\${PRODUCTNAME}.lnk"
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; wayBetter: shortcuts that an install from before the rename left under the old name
|
||||||
|
!ifdef LEGACYNAME
|
||||||
|
Call un.RemoveLegacyShortcuts
|
||||||
|
!endif
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; Remove registry information for add/remove programs
|
||||||
|
!if "${INSTALLMODE}" == "both"
|
||||||
|
DeleteRegKey SHCTX "${UNINSTKEY}"
|
||||||
|
!else if "${INSTALLMODE}" == "perMachine"
|
||||||
|
DeleteRegKey HKLM "${UNINSTKEY}"
|
||||||
|
!else
|
||||||
|
DeleteRegKey HKCU "${UNINSTKEY}"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Removes the Autostart entry for ${PRODUCTNAME} from the HKCU Run key if it exists.
|
||||||
|
; This ensures the program does not launch automatically after uninstallation if it exists.
|
||||||
|
; If it doesn't exist, it does nothing.
|
||||||
|
; We do this when not updating (to preserve the registry value on updates)
|
||||||
|
${If} $UpdateMode <> 1
|
||||||
|
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${PRODUCTNAME}"
|
||||||
|
!ifdef LEGACYNAME
|
||||||
|
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${LEGACYNAME}"
|
||||||
|
!endif
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; Delete app data if the checkbox is selected
|
||||||
|
; and if not updating
|
||||||
|
${If} $DeleteAppDataCheckboxState = 1
|
||||||
|
${AndIf} $UpdateMode <> 1
|
||||||
|
; Clear the install location $INSTDIR from registry
|
||||||
|
DeleteRegKey SHCTX "${MANUPRODUCTKEY}"
|
||||||
|
DeleteRegKey /ifempty SHCTX "${MANUKEY}"
|
||||||
|
|
||||||
|
; Clear the install language from registry
|
||||||
|
DeleteRegValue HKCU "${MANUPRODUCTKEY}" "Installer Language"
|
||||||
|
DeleteRegKey /ifempty HKCU "${MANUPRODUCTKEY}"
|
||||||
|
DeleteRegKey /ifempty HKCU "${MANUKEY}"
|
||||||
|
|
||||||
|
SetShellVarContext current
|
||||||
|
RmDir /r "$APPDATA\${BUNDLEID}"
|
||||||
|
RmDir /r "$LOCALAPPDATA\${BUNDLEID}"
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
!ifmacrodef NSIS_HOOK_POSTUNINSTALL
|
||||||
|
!insertmacro NSIS_HOOK_POSTUNINSTALL
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; Auto close if passive mode or updating
|
||||||
|
${If} $PassiveMode = 1
|
||||||
|
${OrIf} $UpdateMode = 1
|
||||||
|
SetAutoClose true
|
||||||
|
${EndIf}
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Function RestorePreviousInstallLocation
|
||||||
|
ReadRegStr $4 SHCTX "${MANUPRODUCTKEY}" ""
|
||||||
|
StrCmp $4 "" +2 0
|
||||||
|
StrCpy $INSTDIR $4
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Function Skip
|
||||||
|
Abort
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Function SkipIfPassive
|
||||||
|
${IfThen} $PassiveMode = 1 ${|} Abort ${|}
|
||||||
|
FunctionEnd
|
||||||
|
Function un.SkipIfPassive
|
||||||
|
${IfThen} $PassiveMode = 1 ${|} Abort ${|}
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
; wayBetter: an install from before a rename has "${LEGACYNAME}.lnk" shortcuts. One that points at
|
||||||
|
; this app is replaced by "${PRODUCTNAME}.lnk" in the same folder (same target and AppUserModelID),
|
||||||
|
; also on /UPDATE, so Start, the desktop and Windows notifications show the new name. Shortcuts
|
||||||
|
; that point anywhere else are left alone. Nothing to do for an app that was never renamed.
|
||||||
|
!macro MigrateLegacyShortcut dir
|
||||||
|
!ifdef LEGACYNAME
|
||||||
|
!insertmacro IsShortcutTarget "${dir}\${LEGACYNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
Pop $0
|
||||||
|
${If} $0 = 1
|
||||||
|
Delete "${dir}\${LEGACYNAME}.lnk"
|
||||||
|
CreateShortcut "${dir}\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
!insertmacro SetLnkAppUserModelId "${dir}\${PRODUCTNAME}.lnk"
|
||||||
|
${EndIf}
|
||||||
|
!endif
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
!ifdef LEGACYNAME
|
||||||
|
Function un.RemoveLegacyShortcuts
|
||||||
|
!insertmacro IsShortcutTarget "$SMPROGRAMS\${LEGACYNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
Pop $0
|
||||||
|
${If} $0 = 1
|
||||||
|
!insertmacro UnpinShortcut "$SMPROGRAMS\${LEGACYNAME}.lnk"
|
||||||
|
Delete "$SMPROGRAMS\${LEGACYNAME}.lnk"
|
||||||
|
${EndIf}
|
||||||
|
!insertmacro IsShortcutTarget "$DESKTOP\${LEGACYNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
Pop $0
|
||||||
|
${If} $0 = 1
|
||||||
|
!insertmacro UnpinShortcut "$DESKTOP\${LEGACYNAME}.lnk"
|
||||||
|
Delete "$DESKTOP\${LEGACYNAME}.lnk"
|
||||||
|
${EndIf}
|
||||||
|
FunctionEnd
|
||||||
|
!endif
|
||||||
|
|
||||||
|
Function CreateOrUpdateStartMenuShortcut
|
||||||
|
!insertmacro MigrateLegacyShortcut "$SMPROGRAMS"
|
||||||
|
!if "${STARTMENUFOLDER}" != ""
|
||||||
|
!insertmacro MigrateLegacyShortcut "$SMPROGRAMS\$AppStartMenuFolder"
|
||||||
|
!endif
|
||||||
|
|
||||||
|
; We used to use product name as MAINBINARYNAME
|
||||||
|
; migrate old shortcuts to target the new MAINBINARYNAME
|
||||||
|
StrCpy $R0 0
|
||||||
|
|
||||||
|
!insertmacro IsShortcutTarget "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\$OldMainBinaryName"
|
||||||
|
Pop $0
|
||||||
|
${If} $0 = 1
|
||||||
|
!insertmacro SetShortcutTarget "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
StrCpy $R0 1
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
!insertmacro IsShortcutTarget "$SMPROGRAMS\${PRODUCTNAME}.lnk" "$INSTDIR\$OldMainBinaryName"
|
||||||
|
Pop $0
|
||||||
|
${If} $0 = 1
|
||||||
|
!insertmacro SetShortcutTarget "$SMPROGRAMS\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
StrCpy $R0 1
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
${If} $R0 = 1
|
||||||
|
Return
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; Skip creating shortcut if in update mode or no shortcut mode
|
||||||
|
; but always create if migrating from wix
|
||||||
|
${If} $WixMode = 0
|
||||||
|
${If} $UpdateMode = 1
|
||||||
|
${OrIf} $NoShortcutMode = 1
|
||||||
|
Return
|
||||||
|
${EndIf}
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
!if "${STARTMENUFOLDER}" != ""
|
||||||
|
CreateDirectory "$SMPROGRAMS\$AppStartMenuFolder"
|
||||||
|
CreateShortcut "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
!insertmacro SetLnkAppUserModelId "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk"
|
||||||
|
!else
|
||||||
|
CreateShortcut "$SMPROGRAMS\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
!insertmacro SetLnkAppUserModelId "$SMPROGRAMS\${PRODUCTNAME}.lnk"
|
||||||
|
!endif
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Function CreateOrUpdateDesktopShortcut
|
||||||
|
!insertmacro MigrateLegacyShortcut "$DESKTOP"
|
||||||
|
|
||||||
|
; We used to use product name as MAINBINARYNAME
|
||||||
|
; migrate old shortcuts to target the new MAINBINARYNAME
|
||||||
|
!insertmacro IsShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\$OldMainBinaryName"
|
||||||
|
Pop $0
|
||||||
|
${If} $0 = 1
|
||||||
|
!insertmacro SetShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
Return
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
; Skip creating shortcut if in update mode or no shortcut mode
|
||||||
|
; but always create if migrating from wix
|
||||||
|
${If} $WixMode = 0
|
||||||
|
${If} $UpdateMode = 1
|
||||||
|
${OrIf} $NoShortcutMode = 1
|
||||||
|
Return
|
||||||
|
${EndIf}
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
CreateShortcut "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINBINARYNAME}.exe"
|
||||||
|
!insertmacro SetLnkAppUserModelId "$DESKTOP\${PRODUCTNAME}.lnk"
|
||||||
|
FunctionEnd
|
||||||
Loading…
Add table
Add a link
Reference in a new issue