MCPcopy
hub / github.com/ZToolsCenter/ZTools / syncWindowsUninstallVersion

Function syncWindowsUninstallVersion

src/main/utils/registrySync.ts:67–93  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65 * the NSIS-installed registry entry with the old version.
66 */
67export async function syncWindowsUninstallVersion(): Promise<void> {
68 if (process.platform !== 'win32') return
69 if (!app.isPackaged) return
70
71 const currentVersion = app.getVersion()
72 const productName = app.getName()
73
74 try {
75 const keyPath = await findUninstallKeyPath(productName)
76 if (!keyPath) {
77 console.log('[RegistrySync] No uninstall registry entry found (portable install?)')
78 return
79 }
80
81 const registryVersion = await getRegistryValue(keyPath, 'DisplayVersion')
82 if (registryVersion === currentVersion) return
83
84 const success = await setRegistryValue(keyPath, 'DisplayVersion', currentVersion)
85 if (success) {
86 console.log(`[RegistrySync] Updated DisplayVersion: ${registryVersion} -> ${currentVersion}`)
87 } else {
88 console.warn('[RegistrySync] Failed to update DisplayVersion (insufficient permissions?)')
89 }
90 } catch (error) {
91 console.error('[RegistrySync] Error syncing registry version:', error)
92 }
93}

Callers 1

initMethod · 0.85

Calls 3

findUninstallKeyPathFunction · 0.85
getRegistryValueFunction · 0.85
setRegistryValueFunction · 0.85

Tested by

no test coverage detected