diff options
Diffstat (limited to 'src/vs/platform/update/electron-main/updateService.win32.ts')
-rw-r--r-- | src/vs/platform/update/electron-main/updateService.win32.ts | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/vs/platform/update/electron-main/updateService.win32.ts b/src/vs/platform/update/electron-main/updateService.win32.ts index 781e766b7f7..e3661ce4bbc 100644 --- a/src/vs/platform/update/electron-main/updateService.win32.ts +++ b/src/vs/platform/update/electron-main/updateService.win32.ts @@ -47,6 +47,14 @@ function getUpdateType(): UpdateType { return _updateType; } +function validateUpdateModeValue(value: string | undefined): 'none' | 'manual' | 'start' | 'default' | undefined { + if (value === 'none' || value === 'manual' || value === 'start' || value === 'default') { + return value; + } else { + return undefined; + } +} + export class Win32UpdateService extends AbstractUpdateService { private availableUpdate: IAvailableUpdate | undefined; @@ -71,8 +79,24 @@ export class Win32UpdateService extends AbstractUpdateService { super(lifecycleMainService, configurationService, environmentMainService, requestService, logService, productService); } - override initialize(): void { - super.initialize(); + protected override async getUpdateMode(): Promise<'none' | 'manual' | 'start' | 'default'> { + if (this.productService.win32RegValueName) { + const policyKey = `Software\\Policies\\Microsoft\\${this.productService.win32RegValueName}`; + const [hklm, hkcu] = await Promise.all([ + this.nativeHostMainService.windowsGetStringRegKey(undefined, 'HKEY_LOCAL_MACHINE', policyKey, 'UpdateMode').then(validateUpdateModeValue), + this.nativeHostMainService.windowsGetStringRegKey(undefined, 'HKEY_CURRENT_USER', policyKey, 'UpdateMode').then(validateUpdateModeValue) + ]); + + if (hklm) { + this.logService.info(`update#getUpdateMode: 'UpdateMode' policy defined in 'HKLM\\${policyKey}':`, hklm); + return hklm; + } else if (hkcu) { + this.logService.info(`update#getUpdateMode: 'UpdateMode' policy defined in 'HKCU\\${policyKey}':`, hkcu); + return hkcu; + } + } + + return await super.getUpdateMode(); } protected buildUpdateFeedUrl(quality: string): string | undefined { |