Skip to content
TypeScript

fix(desktop): name the running app in Windows installer prompts (#27886)

Yash Singhe5909e53c32a
diff --git a/apps/desktop/resources/installer.nsh b/apps/desktop/resources/installer.nsh
index 092f641c335..7f277fdcbf9 100644
--- a/apps/desktop/resources/installer.nsh
+++ b/apps/desktop/resources/installer.nsh
@@ -1,3 +1,35 @@
+!include "StrFunc.nsh"
+!ifdef BUILD_UNINSTALLER
+ ${UnStrRep}
+ !define T3StrRep '${UnStrRep}'
+!else
+ ${StrRep}
+ !define T3StrRep '${StrRep}'
+!endif
+
+!macro customAppRunningMessages
+ Push $0
+ Push $1
+ ${If} $IsPowerShellAvailable == 0
+ System::Call 'kernel32::SetEnvironmentVariable(t "T3CODE_INSTALL_DIR", t "$INSTDIR")'
+ nsExec::ExecToStack `"$PowerShellPath" -NoProfile -NonInteractive -C "Get-CimInstance -ClassName Win32_Process | Where-Object { $$_.ExecutablePath -and [IO.Path]::GetDirectoryName($$_.ExecutablePath) -eq $$env:T3CODE_INSTALL_DIR } | ForEach-Object { [IO.Path]::GetFileNameWithoutExtension($$_.ExecutablePath) } | Where-Object { $$_ -in 'T3 Code (Alpha)', 'T3 Code (Beta)', 'T3 Code (Nightly)' } | Select-Object -First 1 | ForEach-Object { [Console]::Write($$_) }"`
+ Pop $0
+ Pop $1
+ System::Call 'kernel32::SetEnvironmentVariable(t "T3CODE_INSTALL_DIR", p 0)'
+ ${If} $0 == 0
+ ${If} $1 == "T3 Code (Alpha)"
+ ${OrIf} $1 == "T3 Code (Beta)"
+ ${OrIf} $1 == "T3 Code (Nightly)"
+ ${T3StrRep} $appRunningMessage $appRunningMessage "${PRODUCT_NAME}" $1
+ ${T3StrRep} $appClosingMessage $appClosingMessage "${PRODUCT_NAME}" $1
+ ${T3StrRep} $appCannotBeClosedMessage $appCannotBeClosedMessage "${PRODUCT_NAME}" $1
+ ${EndIf}
+ ${EndIf}
+ ${EndIf}
+ Pop $1
+ Pop $0
+!macroend
+
!macro customInstall
!ifndef DO_NOT_CREATE_START_MENU_SHORTCUT
${IfNot} ${FileExists} "$newStartMenuLink"
diff --git a/patches/[email protected] b/patches/[email protected]
index 72655d9f0a6..9df8acd7ab8 100644
--- a/patches/[email protected]
+++ b/patches/[email protected]
@@ -13,3 +13,51 @@ index 8a3462b185b078a260483635e6d774e2ece6e269..105778c145ab63a26444179215c643a7
try {
await nsisUtil_1.UninstallerReader.exec(installerPath, uninstallerPath);
}
+diff --git a/templates/nsis/include/allowOnlyOneInstallerInstance.nsh b/templates/nsis/include/allowOnlyOneInstallerInstance.nsh
+--- a/templates/nsis/include/allowOnlyOneInstallerInstance.nsh
++++ b/templates/nsis/include/allowOnlyOneInstallerInstance.nsh
+@@ -103,6 +103,9 @@
+ !macroend
+
+ !macro _CHECK_APP_RUNNING
++ Var /GLOBAL appRunningMessage
++ Var /GLOBAL appClosingMessage
++ Var /GLOBAL appCannotBeClosedMessage
+ ${GetProcessInfo} 0 $pid $1 $2 $3 $4
+ ${if} $3 != "${APP_EXECUTABLE_FILENAME}"
+ ${if} ${isUpdated}
+@@ -112,17 +115,23 @@
+
+ !insertmacro FIND_PROCESS "${APP_EXECUTABLE_FILENAME}" $R0
+ ${if} $R0 == 0
++ StrCpy $appRunningMessage "$(appRunning)"
++ StrCpy $appClosingMessage "$(appClosing)"
++ StrCpy $appCannotBeClosedMessage "$(appCannotBeClosed)"
++ !ifmacrodef customAppRunningMessages
++ !insertmacro customAppRunningMessages
++ !endif
+ ${if} ${isUpdated}
+ # allow app to exit without explicit kill
+ Sleep 1000
+ Goto doStopProcess
+ ${endIf}
+- MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$(appRunning)" /SD IDOK IDOK doStopProcess
++ MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "$appRunningMessage" /SD IDOK IDOK doStopProcess
+ Quit
+
+ doStopProcess:
+
+- DetailPrint "$(appClosing)"
++ DetailPrint "$appClosingMessage"
+
+ !insertmacro KILL_PROCESS "${APP_EXECUTABLE_FILENAME}" 0
+ # to ensure that files are not "in-use"
+@@ -153,7 +162,7 @@
+ # App likely running with elevated permissions.
+ # Ask user to close it manually
+ ${if} $R1 > 1
+- MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "$(appCannotBeClosed)" /SD IDCANCEL IDRETRY loop
++ MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "$appCannotBeClosedMessage" /SD IDCANCEL IDRETRY loop
+ Quit
+ ${else}
+ Goto loop
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 91c27d37762..9cf8a3f0c53 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -372,7 +372,7 @@ patchedDependencies:
'@react-native-menu/[email protected]': 910ec1bf22aa85a96fcf12299cd823bc30f702dd9b2d77b564d10b9ed709f7f6
'@react-navigation/[email protected]': 990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42
[email protected]: 824006659fa28ca31e490ce1fc3611f77436005ce9fa0f638be46564133cf042
- [email protected]: a28c2dfcfc2b90d6c6247e199e6537391db9ecd941854c650910d607442512d3
+ [email protected]: 0fbe9ae51783f5768ebe197d12d1fdb7d477a08c92e5db2f6356bcce62613c53
[email protected]: cfff57561b0ee59b5addb3b2e6c6f20906e967507a530ab67e8db8108e520ba4
[email protected]: 530af071088a809fe1a97ce2b2269c78335fbb5dcd3893d6937ff5c304c85a0a
[email protected]: f0b0fd100550ed76e5c25b4d13eb7c9ff62825f8f197c53edf7bf447c50c9fb7
@@ -17176,7 +17176,7 @@ snapshots:
- [email protected](patch_hash=a28c2dfcfc2b90d6c6247e199e6537391db9ecd941854c650910d607442512d3)([email protected])([email protected])([email protected]):
+ [email protected](patch_hash=0fbe9ae51783f5768ebe197d12d1fdb7d477a08c92e5db2f6356bcce62613c53)([email protected])([email protected])([email protected]):
dependencies:
'@electron/asar': 3.4.1
'@electron/fuses': 1.8.0
@@ -18026,7 +18026,7 @@ snapshots:
dependencies:
- app-builder-lib: 26.16.1(patch_hash=a28c2dfcfc2b90d6c6247e199e6537391db9ecd941854c650910d607442512d3)([email protected])([email protected])([email protected])
+ app-builder-lib: 26.16.1(patch_hash=0fbe9ae51783f5768ebe197d12d1fdb7d477a08c92e5db2f6356bcce62613c53)([email protected])([email protected])([email protected])
builder-util: 26.16.0([email protected])
fs-extra: 10.1.0
js-yaml: 4.3.2
@@ -18119,7 +18119,7 @@ snapshots:
dependencies:
- app-builder-lib: 26.16.1(patch_hash=a28c2dfcfc2b90d6c6247e199e6537391db9ecd941854c650910d607442512d3)([email protected])([email protected])([email protected])
+ app-builder-lib: 26.16.1(patch_hash=0fbe9ae51783f5768ebe197d12d1fdb7d477a08c92e5db2f6356bcce62613c53)([email protected])([email protected])([email protected])
builder-util: 26.16.0([email protected])
electron-winstaller: 5.4.0([email protected])
transitivePeerDependencies:
@@ -18128,7 +18128,7 @@ snapshots:
dependencies:
- app-builder-lib: 26.16.1(patch_hash=a28c2dfcfc2b90d6c6247e199e6537391db9ecd941854c650910d607442512d3)([email protected])([email protected])([email protected])
+ app-builder-lib: 26.16.1(patch_hash=0fbe9ae51783f5768ebe197d12d1fdb7d477a08c92e5db2f6356bcce62613c53)([email protected])([email protected])([email protected])
builder-util: 26.16.0([email protected])
builder-util-runtime: 9.7.0([email protected])
chalk: 4.1.2