YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
Migrate Windows Enterprise updates to user installation without elevation (#7654)
Ezra Ellette4897bb8ac40a
diff --git a/apps/screenpipe-app-tauri/scripts/enterprise-installer.test.ts b/apps/screenpipe-app-tauri/scripts/enterprise-installer.test.tsindex fbfc48aa6..f758fc643 100644--- a/apps/screenpipe-app-tauri/scripts/enterprise-installer.test.ts+++ b/apps/screenpipe-app-tauri/scripts/enterprise-installer.test.ts@@ -4,7 +4,7 @@import { expect, test } from "bun:test";import { readFileSync } from "node:fs";import { join } from "node:path";-import { mergeConfig } from "./native-build-queue";+import { mergeConfig, parseEnterpriseBundleArgs } from "./native-build-queue";const tauriRoot = join(import.meta.dir, "..", "src-tauri");const enterprise = JSON.parse(readFileSync(join(tauriRoot, "tauri.enterprise.conf.json"), "utf8"));@@ -16,3 +16,13 @@ test("persistence package clears the ordinary custom template and stays machine-expect(merged.bundle.windows.nsis.template).toBeNull();expect(merged.bundle.windows.nsis.installerHooks).toBe("windows/persistent-hooks.nsh");});++test("enterprise bundle keeps QA build bypasses explicit", () => {+ expect(parseEnterpriseBundleArgs(["--build", "--updater-artifacts", "--ignore-version-mismatches", "--config", "qa.json"])).toEqual({+ build: true,+ updaterArtifacts: true,+ upstreamTemplate: false,+ ignoreVersionMismatches: true,+ bundleArgs: ["--config", "qa.json"],+ });+});diff --git a/apps/screenpipe-app-tauri/scripts/native-build-queue.ts b/apps/screenpipe-app-tauri/scripts/native-build-queue.tsindex 10e929fe6..2f9c61a89 100644--- a/apps/screenpipe-app-tauri/scripts/native-build-queue.ts+++ b/apps/screenpipe-app-tauri/scripts/native-build-queue.ts@@ -88,6 +88,27 @@ export function nativeTestCommand(args: string[]): string[] {];}+export function parseEnterpriseBundleArgs(args: string[]): {+ build: boolean;+ updaterArtifacts: boolean;+ upstreamTemplate: boolean;+ ignoreVersionMismatches: boolean;+ bundleArgs: string[];+} {+ return {+ build: args.includes("--build"),+ updaterArtifacts: args.includes("--updater-artifacts"),+ upstreamTemplate: args.includes("--upstream-template"),+ ignoreVersionMismatches: args.includes("--ignore-version-mismatches"),+ bundleArgs: args.filter((arg) => ![+ "--upstream-template",+ "--build",+ "--updater-artifacts",+ "--ignore-version-mismatches",+ ].includes(arg)),+ };+}+function decode(value: Uint8Array): string {return new TextDecoder().decode(value).trim();}@@ -187,7 +208,7 @@ function persistentEnterpriseConfig(target: string): string {return JSON.stringify(mergeConfig(enterprise, persistence));}-function unsignedEnterpriseConfig(): string {+function unsignedEnterpriseConfig(createUpdaterArtifacts = false): string {const enterprise = JSON.parse(readFileSync(join(APP_ROOT, "src-tauri", "tauri.enterprise.conf.json"),"utf8",@@ -198,14 +219,14 @@ function unsignedEnterpriseConfig(): string {));return JSON.stringify(mergeConfig(mergeConfig(enterprise, windows), {bundle: {- createUpdaterArtifacts: false,+ createUpdaterArtifacts,windows: { signCommand: null },},}));}-function upstreamMachineEnterpriseConfig(): string {- return JSON.stringify(mergeConfig(JSON.parse(unsignedEnterpriseConfig()), {+function upstreamMachineEnterpriseConfig(createUpdaterArtifacts = false): string {+ return JSON.stringify(mergeConfig(JSON.parse(unsignedEnterpriseConfig(createUpdaterArtifacts)), {bundle: { windows: { nsis: { installMode: "perMachine", template: null } } },}));}@@ -504,14 +525,25 @@ async function perform(mode: BuildMode, args: string[]): Promise<number> {}case "enterprise-bundle": {const target = "x86_64-pc-windows-msvc";- const upstreamTemplate = args.includes("--upstream-template");- const bundleArgs = args.filter((arg) => arg !== "--upstream-template");+ const { build, updaterArtifacts, upstreamTemplate, ignoreVersionMismatches, bundleArgs } =+ parseEnterpriseBundleArgs(args);+ const config = upstreamTemplate+ ? upstreamMachineEnterpriseConfig(updaterArtifacts)+ : unsignedEnterpriseConfig(updaterArtifacts);+ if (build) {+ const buildArgs = [+ "bun", "tauri", "build", "--no-bundle", "--target", target,+ "--features", "enterprise-build", "--config", config,+ ...bundleArgs,+ ];+ if (ignoreVersionMismatches) buildArgs.splice(8, 0, "--ignore-version-mismatches");+ const exitCode = await run(buildArgs, env);+ if (exitCode !== 0) return exitCode;+ }return run(["bun", "tauri", "bundle", "--target", target,"--features", "enterprise-build", "--bundles", "nsis",- "--config", upstreamTemplate- ? upstreamMachineEnterpriseConfig()- : unsignedEnterpriseConfig(),+ "--config", config,...bundleArgs,], env);}diff --git a/apps/screenpipe-app-tauri/scripts/windows-enterprise-installer.integration.ps1 b/apps/screenpipe-app-tauri/scripts/windows-enterprise-installer.integration.ps1index 07932ef58..59f4f2e36 100644--- a/apps/screenpipe-app-tauri/scripts/windows-enterprise-installer.integration.ps1+++ b/apps/screenpipe-app-tauri/scripts/windows-enterprise-installer.integration.ps1@@ -78,7 +78,10 @@ static class ProofPayload {}"@[IO.File]::WriteAllText($source, $code, [Text.UTF8Encoding]::new($false))- $csc = Join-Path ([Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory()) "csc.exe"+ $csc = Join-Path $env:WINDIR "Microsoft.NET\Framework64\v4.0.30319\csc.exe"+ if (-not (Test-Path -LiteralPath $csc)) {+ $csc = Join-Path $env:WINDIR "Microsoft.NET\Framework\v4.0.30319\csc.exe"+ }& $csc /nologo /target:winexe /optimize+ /reference:System.Windows.Forms.dll /out:$output $sourceif ($LASTEXITCODE -or -not (Test-Path $output)) { throw "proof payload $Label compilation failed" }return $output@@ -121,6 +124,10 @@ $installerA = Join-Path $fixtureDir "screenpipe-enterprise-A.exe"$installerB = Join-Path $fixtureDir "screenpipe-enterprise-B.exe"$legacyInstallerA = Join-Path $fixtureDir "screenpipe-enterprise-legacy-machine-A.exe"if (-not $InstallOnly) {+ $releasePayload = Join-Path $releaseDir "screenpipe-app.exe"+ $savedPayload = Join-Path $fixtureDir ("original-payload-" + [Guid]::NewGuid() + ".exe")+ $hadPayload = Test-Path -LiteralPath $releasePayload+ if ($hadPayload) { Copy-Item -LiteralPath $releasePayload -Destination $savedPayload }Push-Location $appRoottry {$payloadA = Build-ProofPayload "A"@@ -130,6 +137,12 @@ if (-not $InstallOnly) {$legacyInstallerA = Build-Fixture "legacy-machine-A" "91.0.0" $payloadA $true} finally {Pop-Location+ if ($hadPayload) {+ Copy-Item -LiteralPath $savedPayload -Destination $releasePayload -Force+ Remove-Item -LiteralPath $savedPayload+ } else {+ Remove-Item -LiteralPath $releasePayload -Force -ErrorAction SilentlyContinue+ }}}@@ -165,29 +178,78 @@ if ($registeredA.DisplayVersion -ne "91.0.0" -or $registeredA.InstallLocation.Trthrow "A registry scope/version/path mismatch"}$hashA = (Get-FileHash (Join-Path $installDir "screenpipe-app.exe") -Algorithm SHA256).Hash+$machineVersion = $registeredA.DisplayVersion+$machineLocation = $registeredA.InstallLocation+$renamedUserShortcut = Join-Path ([Environment]::GetFolderPath("Desktop")) "Renamed Screenpipe fixture.lnk"+$startupKey = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run"+if ($Matrix -ne "current") {+ $shell = New-Object -ComObject WScript.Shell+ $shortcut = $shell.CreateShortcut($renamedUserShortcut)+ $shortcut.TargetPath = Join-Path $installDir "screenpipe-app.exe"+ $shortcut.Save()+ New-Item $startupKey -Force | Out-Null+ Set-ItemProperty $startupKey -Name "screenpipe enterprise" -Value ('"' + (Join-Path $installDir "screenpipe-app.exe") + '" --autostart')+}# Matches Tauri's normal update mode; /D is final by NSIS contract.# Existing scope and destination must be detected without /D or /SPALLUSERS.Invoke-Installer $installerB @("/S", "/P", "/UPDATE")+$migratedInstallDir = if ($Matrix -ne "current") {+ Join-Path $localAppData "screenpipe enterprise"+} else {+ $installDir+}+$registryRoot = if ($Matrix -ne "current") { "HKCU:" } else { $registryRoot }+$uninstallKey = "$registryRoot\Software\Microsoft\Windows\CurrentVersion\Uninstall\screenpipe enterprise"$registeredB = Get-ItemProperty $uninstallKey-$hashB = (Get-FileHash (Join-Path $installDir "screenpipe-app.exe") -Algorithm SHA256).Hash+$hashB = (Get-FileHash (Join-Path $migratedInstallDir "screenpipe-app.exe") -Algorithm SHA256).Hashif ($registeredB.DisplayVersion -ne "92.0.0" -or $hashA -eq $hashB) {throw "B did not replace A with distinct version and bytes"}if (-not (Test-Path -LiteralPath $sentinel)) { throw "actual app-data sentinel was removed" }-if (Test-Path "$otherRegistryRoot\Software\Microsoft\Windows\CurrentVersion\Uninstall\screenpipe enterprise") {+if ($Matrix -ne "current") {+ $machineRegistration = Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\screenpipe enterprise"+ if ($machineRegistration.DisplayVersion -ne $machineVersion -or+ $machineRegistration.InstallLocation -ne $machineLocation -or+ -not (Test-Path (Join-Path $installDir "screenpipe-app.exe"))) {+ throw "migration modified the legacy machine installation"+ }+ $migratedExecutable = Join-Path $migratedInstallDir "screenpipe-app.exe"+ $shell = New-Object -ComObject WScript.Shell+ $shortcutTarget = $shell.CreateShortcut($renamedUserShortcut).TargetPath+ if ($shortcutTarget -ne $migratedExecutable) {+ throw "migration did not retarget the existing renamed user shortcut: $shortcutTarget"+ }+ $screenpipeLinks = Get-ChildItem ([Environment]::GetFolderPath("Desktop")) -Filter *.lnk | Where-Object {+ $shell.CreateShortcut($_.FullName).TargetPath -eq $migratedExecutable+ }+ if ($screenpipeLinks.Count -ne 1) { throw "migration created duplicate user desktop shortcuts" }+ $expectedStartup = '"' + $migratedExecutable + '" --autostart'+ $actualStartup = (Get-ItemProperty $startupKey).'screenpipe enterprise'+ if ($actualStartup -ne $expectedStartup) {+ throw "migration startup value mismatch: $actualStartup"+ }+} elseif (Test-Path "$otherRegistryRoot\Software\Microsoft\Windows\CurrentVersion\Uninstall\screenpipe enterprise") {throw "$Matrix fixture created a duplicate registration in the other scope"}-$uninstaller = Join-Path $installDir "uninstall.exe"+$uninstaller = Join-Path $migratedInstallDir "uninstall.exe"$uninstall = Start-Process -FilePath $uninstaller -ArgumentList "/S" -Wait -PassThruif ($uninstall.ExitCode) { throw "uninstaller exited $($uninstall.ExitCode)" }for ($i = 0; $i -lt 100 -and (Test-Path -LiteralPath $uninstaller); $i++) { Start-Sleep -Milliseconds 100 }if (Test-Path -LiteralPath $uninstaller) { throw "spawned NSIS uninstaller child did not complete" }if (-not (Test-Path -LiteralPath $sentinel)) { throw "uninstall removed actual app-data sentinel" }+if ($Matrix -ne "current") {+ $legacyUninstaller = Join-Path $installDir "uninstall.exe"+ $legacyUninstall = Start-Process -FilePath $legacyUninstaller -ArgumentList "/S" -Wait -PassThru+ if ($legacyUninstall.ExitCode) { throw "legacy uninstaller exited $($legacyUninstall.ExitCode)" }+ Remove-Item $renamedUserShortcut -Force -ErrorAction SilentlyContinue+ Remove-ItemProperty $startupKey -Name "screenpipe enterprise" -ErrorAction SilentlyContinue+}+[pscustomobject]@{- InstallPath = $installDir+ InstallPath = $migratedInstallDirVersion = $registeredB.DisplayVersionHashA = $hashAHashB = $hashBdiff --git a/apps/screenpipe-app-tauri/src-tauri/src/diagnostic_logs.rs b/apps/screenpipe-app-tauri/src-tauri/src/diagnostic_logs.rsindex bf3c9ce6f..1bdf13ed4 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/diagnostic_logs.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/diagnostic_logs.rs@@ -275,11 +275,14 @@ mod tests {}#[tokio::test]- async fn installer_elevation_failure_reaches_redacted_support_bundle() {+ async fn installer_failure_reaches_redacted_support_bundle() {let dir = tempfile::tempdir().unwrap();tokio::fs::write(dir.path().join(crate::update_diagnostics::LOG_NAME),- "installer_elevation_failed: result=1223 scope=all recovery=original_app_relaunch_succeeded [email protected]\n",+ concat!(+ "installer_elevation_failed: result=1223 scope=all recovery=original_app_relaunch_succeeded [email protected]\n",+ "installer_migration_failed: operation=copy_enterprise_config windows_result=5 scope=current recovery=original_app_relaunch_result_0 [email protected]\n",+ ),).await.unwrap();@@ -288,6 +291,8 @@ mod tests {.unwrap();assert!(report.contains("installer_elevation_failed: result=1223"));assert!(report.contains("recovery=original_app_relaunch_succeeded"));+ assert!(report.contains("installer_migration_failed: operation=copy_enterprise_config windows_result=5"));+ assert!(report.contains("recovery=original_app_relaunch_result_0"));assert!(!report.contains("[email protected]"));}diff --git a/apps/screenpipe-app-tauri/src-tauri/windows/enterprise-installer.nsi b/apps/screenpipe-app-tauri/src-tauri/windows/enterprise-installer.nsiindex 822458c3e..f76fc1f14 100644--- a/apps/screenpipe-app-tauri/src-tauri/windows/enterprise-installer.nsi+++ b/apps/screenpipe-app-tauri/src-tauri/windows/enterprise-installer.nsi@@ -95,6 +95,41 @@ Var ElevationResultVar RawCommandLineVar MaintenanceUninstallVar MaintenanceKeep+Var MachineToUserMigration+Var MachineInstallDir+Var MachineMainBinaryName+Var MigrationError++; Tauri's generic shortcut predicate intentionally compares SLGP_RAWPATH with+; exact string semantics. Legacy Shell links can resolve to the same executable+; with different casing or path representation, so migration uses the resolved+; target and Windows' case-insensitive comparison before changing it in place.+!macro RetargetMigrationShortcut shortcut old_target new_target+ ${DisableX64FSRedirection}+ !insertmacro ComHlpr_CreateInProcInstance ${CLSID_ShellLink} ${IID_IShellLink} r0 ""+ ${If} $0 P<> 0+ ${IUnknown::QueryInterface} $0 '("${IID_IPersistFile}", .r1)'+ ${If} $1 P<> 0+ ${IPersistFile::Load} $1 '("${shortcut}", ${STGM_READWRITE})'+ System::Alloc ${MAX_PATH}+ Pop $2+ ${IShellLink::GetPath} $0 '(.r2, ${MAX_PATH}, 0, 0)'+ System::Call 'kernel32::lstrcmpiW(w r2, w "${old_target}") i.r3'+ ${If} $3 != 0+ ${WordReplace} "${old_target}" "$PROGRAMFILES64" "$PROGRAMFILES32" "+1" $4+ System::Call 'kernel32::lstrcmpiW(w r2, w r4) i.r3'+ ${EndIf}+ ${If} $3 = 0+ ${IShellLink::SetPath} $0 '(w "${new_target}")'+ ${IPersistFile::Save} $1 '("${shortcut}", 1)'+ ${EndIf}+ System::Free $2+ ${IUnknown::Release} $1 ""+ ${EndIf}+ ${IUnknown::Release} $0 ""+ ${EndIf}+ ${EnableX64FSRedirection}+!macroendName "${PRODUCTNAME}"BrandingText "${COPYRIGHT}"@@ -544,13 +579,34 @@ Function DetectExistingInstall${AndIf} $1 != ""${AndIf} ${FileExists} "$1\uninstall.exe"${If} $ExistingInstallDir != ""- MessageBox MB_OK|MB_ICONSTOP "Screenpipe has active current-user and all-users installations. Uninstall the copy you no longer want, then run setup again." /SD IDOK- SetErrorLevel 2- Quit+ ; The current-user installation owns updates and ordinary setup runs.+ ; Ignore the orphaned machine registration without requiring cleanup.+ Goto existing_install_detected+ ${EndIf}+ ${If} $UpdateMode = 1+ ; Ordinary Enterprise updates migrate a legacy machine install without+ ; modifying its protected files or HKLM uninstall registration.+ StrCpy $MachineToUserMigration 1+ StrCpy $MachineInstallDir $1+ ; InstallLocation is written quote-delimited by this template. Keep the+ ; detected value intact for normal scope/path preservation, but use a+ ; filesystem path when repairing links or carrying deployment config.+ StrCpy $4 $MachineInstallDir+ System::Call 'shlwapi::PathUnquoteSpacesW(w r4)'+ StrCpy $MachineInstallDir $4+ ReadRegStr $MachineMainBinaryName HKLM "${UNINSTKEY}" "MainBinaryName"+ ${If} $MachineMainBinaryName == ""+ StrCpy $MachineMainBinaryName "${MAINBINARYNAME}.exe"+ ${EndIf}+ Call SetCurrentUserScope+ StrCpy $ExistingScope ""+ StrCpy $ExistingInstallDir ""+ Goto existing_install_detected${EndIf}StrCpy $ExistingScope "all"StrCpy $ExistingInstallDir $1${EndIf}+ existing_install_detected:${If} $IncomingInstallDir != ""${AndIf} $ExistingInstallDir != ""${AndIf} $IncomingInstallDir != $ExistingInstallDir@@ -853,7 +909,9 @@ Function .onInit!if "${INSTALLMODE}" == "both"Call DetectExistingInstall- ${If} $IncomingInstallDir != ""+ ${If} $MachineToUserMigration = 1+ StrCpy $INSTDIR $CurrentUserDefaultDir+ ${ElseIf} $IncomingInstallDir != ""StrCpy $INSTDIR $IncomingInstallDir${ElseIf} $ExistingInstallDir != ""StrCpy $INSTDIR $ExistingInstallDir@@ -1046,6 +1104,8 @@ Section InstallFile /a "/oname={{this.[1]}}" "{{no-escape @key}}"{{/each}}+ Call PreserveMigrationDeploymentConfig+; Copy external binaries{{#each binaries}}File /a "/oname={{this}}" "{{no-escape @key}}"@@ -1088,6 +1148,16 @@ Section Install; Save current MAINBINARYNAME for future updatesWriteRegStr SHCTX "${UNINSTKEY}" "MainBinaryName" "${MAINBINARYNAME}.exe"+ ${If} $MachineToUserMigration = 1+ ; The autostart plugin considers an existing Run value enrolled even when+ ; it still names Program Files. Preserve the user's enrollment choice, but+ ; make an enrolled value launch the newly managed user copy.+ ReadRegStr $0 HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${PRODUCTNAME}"+ ${If} $0 != ""+ WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${PRODUCTNAME}" "$\"$INSTDIR\${MAINBINARYNAME}.exe$\" --autostart"+ ${EndIf}+ ${EndIf}+; Registry information for add/remove programsWriteRegStr SHCTX "${UNINSTKEY}" "DisplayName" "${PRODUCTNAME}"WriteRegStr SHCTX "${UNINSTKEY}" "DisplayIcon" "$\"$INSTDIR\${MAINBINARYNAME}.exe$\""@@ -1336,7 +1406,55 @@ Function un.SkipIfPassive${IfThen} $PassiveMode = 1 ${|} Abort ${|}FunctionEnd+Function PreserveMigrationDeploymentConfig+ ${If} $MachineToUserMigration = 1+ ${AndIf} ${FileExists} "$MachineInstallDir\enterprise.json"+ ${AndIfNot} ${FileExists} "$INSTDIR\enterprise.json"+ ; Preserve the optional executable-adjacent deployment configuration.+ ; A configuration supplied by the candidate installer takes precedence.+ System::Call 'kernel32::CopyFileW(w "$MachineInstallDir\enterprise.json", w "$INSTDIR\enterprise.json", i 1) i.r0 ?e'+ Pop $MigrationError+ ${If} $0 = 0+ ; CopyFile can leave an incomplete destination on failure. It was absent+ ; before this attempt; leave a concurrently created file untouched.+ ; Windows: ERROR_FILE_EXISTS = 80, ERROR_ALREADY_EXISTS = 183.+ ${If} $MigrationError != 80+ ${AndIf} $MigrationError != 183+ Delete "$INSTDIR\enterprise.json"+ ${EndIf}+ ; Keep the old app usable when its configuration cannot be carried over.+ ; This log is included by normal, consented support collection.+ ReadEnvStr $R0 "SCREENPIPE_DATA_DIR"+ ${If} $R0 == ""+ StrCpy $R0 "$PROFILE\.screenpipe"+ ${EndIf}+ CreateDirectory "$R0"+ ClearErrors+ ${GetOptions} $CMDLINE "/ARGS" $R2+ ${If} ${Errors}+ StrCpy $R2 ""+ ${EndIf}+ nsis_tauri_utils::RunAsUser "$MachineInstallDir\$MachineMainBinaryName" "$R2"+ Pop $R1+ FileOpen $1 "$R0\update-install.log" a+ FileSeek $1 0 END+ FileWrite $1 'installer_migration_failed: operation=copy_enterprise_config windows_result=$MigrationError scope=current recovery=original_app_relaunch_result_$R1$\r$\n'+ FileClose $1+ SetErrorLevel $MigrationError+ Quit+ ${EndIf}+ ${EndIf}+FunctionEnd+Function CreateOrUpdateStartMenuShortcut+ ${If} $MachineToUserMigration = 1+ ; Only repair links owned by the current user. Shared links can require+ ; elevation and intentionally remain outside ordinary update management.+ !insertmacro RetargetMigrationShortcut "$SMPROGRAMS\$AppStartMenuFolder\${PRODUCTNAME}.lnk" "$MachineInstallDir\$MachineMainBinaryName" "$INSTDIR\${MAINBINARYNAME}.exe"+ !insertmacro RetargetMigrationShortcut "$SMPROGRAMS\${PRODUCTNAME}.lnk" "$MachineInstallDir\$MachineMainBinaryName" "$INSTDIR\${MAINBINARYNAME}.exe"+ Return+ ${EndIf}+; We used to use product name as MAINBINARYNAME; migrate old shortcuts to target the new MAINBINARYNAMEStrCpy $R0 0@@ -1359,8 +1477,7 @@ Function CreateOrUpdateStartMenuShortcutReturn${EndIf}- ; Skip creating shortcut if in update mode or no shortcut mode- ; but always create if migrating from wix+ ; Skip creating shortcut on an update, but always create if migrating from wix.${If} $WixMode = 0${If} $UpdateMode = 1${OrIf} $NoShortcutMode = 1@@ -1379,6 +1496,21 @@ Function CreateOrUpdateStartMenuShortcutFunctionEndFunction CreateOrUpdateDesktopShortcut+ ${If} $MachineToUserMigration = 1+ ; Desktop links may have been renamed. Retarget every existing user-owned+ ; link that actually names the legacy executable, without creating a new+ ; shortcut or touching the shared desktop.+ FindFirst $R0 $R1 "$DESKTOP\*.lnk"+ migration_desktop_shortcut_loop:+ StrCmp $R1 "" migration_desktop_shortcut_done+ !insertmacro RetargetMigrationShortcut "$DESKTOP\$R1" "$MachineInstallDir\$MachineMainBinaryName" "$INSTDIR\${MAINBINARYNAME}.exe"+ FindNext $R0 $R1+ Goto migration_desktop_shortcut_loop+ migration_desktop_shortcut_done:+ FindClose $R0+ Return+ ${EndIf}+; We used to use product name as MAINBINARYNAME; migrate old shortcuts to target the new MAINBINARYNAME!insertmacro IsShortcutTarget "$DESKTOP\${PRODUCTNAME}.lnk" "$INSTDIR\$OldMainBinaryName"@@ -1388,8 +1520,7 @@ Function CreateOrUpdateDesktopShortcutReturn${EndIf}- ; Skip creating shortcut if in update mode or no shortcut mode- ; but always create if migrating from wix+ ; Skip creating shortcut on an update, but always create if migrating from wix.${If} $WixMode = 0${If} $UpdateMode = 1${OrIf} $NoShortcutMode = 1