fix(windows): UCPD が保護するタスクバー設定値の拒否で apply が中断しないようにする - #69
Merged
Conversation
Windows 11 の User Choice Protection Driver (UCPD.sys) は保護対象の値名への レジストリ書き込みをカーネルのレジストリコールバックで傍受し、呼び出し元が deny-list (reg.exe / powershell.exe 等) の場合に ACCESS_DENIED を返す。 TaskbarDa と ShellFeedsTaskbarViewMode がこれに該当するため system_settings.ps1 が UnauthorizedAccessException で停止し、 run_once_before_02_windows.ps1 が exit 1 となって apply 全体が中断していた。 該当する 2 値のみ Set-UcpdProtectedDword 経由に変更し、拒否は警告して スキップ、それ以外の失敗は再スローする。これらの値を変更するには Microsoft 署名バイナリ (設定アプリ) が必要。 実測 (Windows 11 25H2 / build 26200): - reg add / Set-ItemProperty のいずれでも TaskbarDa と ShellFeedsTaskbarViewMode は拒否される - 同じキーの TaskbarMn / ShowCopilotButton / IsBatteryPercentageEnabled / ShowSecondsInSystemClock は成功する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Windows 11 の User Choice Protection Driver (UCPD.sys) が保護する 2 つのタスクバー設定値への書き込みが
ACCESS_DENIEDになり、chezmoi applyが.chezmoiscripts/02_windows.ps1: exit status 1で中断していた。該当値の拒否のみ警告扱いにして続行する。UCPD.sys は保護対象の値名へのレジストリ書き込みをカーネルのレジストリコールバックで傍受し、呼び出し元プロセスが deny-list (
reg.exe/powershell.exe等) の場合にACCESS_DENIEDを返す。TaskbarDaとShellFeedsTaskbarViewModeがこれに該当するため、スクリプトからは原理的に変更できない (変更には Microsoft 署名バイナリ = 設定アプリが必要)。変更内容
install/windows/system_settings.ps1にSet-UcpdProtectedDwordを追加し、TaskbarDaとShellFeedsTaskbarViewModeの書き込みをそれ経由にしたUnauthorizedAccessExceptionのみ警告してスキップし、それ以外の失敗は再スローする ($ErrorActionPreference = 'Stop'経由で例外が包まれる場合に備え、例外チェーンとFullyQualifiedErrorIdの両方で判定)関連 Issue
なし
動作確認
mise run pre-commitが通った (PSScriptAnalyzer 含む全 hook Passed)mise run testが通った (45 ok / 1 not ok。失敗は[common] dotfilesの~/.ssh/config存在チェックで、エージェント sandbox の read deny による既知の偽失敗。sandbox を外してbats tests/files/common.batsを実行すると ok になることを確認済み)mise run dry-run— 未実行。install/はhome/配下ではなく chezmoi の管理対象ファイルではないため apply 差分に現れない。加えて--verbose付き dry-run は secret ファイルの実値が unified diff に出る経路のため回避した追加の確認:
New-ItemPropertyをスタブ化)。(1)UnauthorizedAccessException→ スキップ、(2) 他の例外 → 再スロー、(3)FullyQualifiedErrorIdのみ一致 → スキップ の 3 系統が期待どおりreg addとSet-ItemPropertyの両方が該当 2 値のみ拒否し、同キーのTaskbarMn/ShowCopilotButton/IsBatteryPercentageEnabled/ShowSecondsInSystemClockは成功することを確認チェックリスト
補足情報
UCPD.sys の deny-list と参照レジストリ値の解析: https://kolbi.cz/blog/2024/04/03/userchoice-protection-driver-ucpd-sys/
ウィジェットとニュースを非表示にしたい場合は、設定アプリ (個人用設定 → タスクバー) から手動で行う必要がある。
別件の未解決事項として、同じ端末では
root\cimv2への WMI クエリがWBEM_E_ACCESS_DENIEDになり、get.chezmoi.io/ps1の Windows PowerShell 5.1 経路 (Get-CimInstance Win32_Processorによる CPU アーキテクチャ判定) が失敗する。本 PR の対象外。