. "$PSScriptRoot\_common.ps1" # Apply UI/IME settings to (a) Default profile NTUSER.DAT (so brand-new users # inherit) and (b) every currently-loaded real-user hive (so re-runs against # an already-logged-in box still take effect immediately on those users). function Apply-UiImeSettings { param([string]$base) # e.g. "Registry::HKU\SetupDefault" or "Registry::HKEY_USERS\" $adv = "$base\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" Set-RegValue $adv 'HideFileExt' 0 Set-RegValue $adv 'Hidden' 1 Set-RegValue $adv 'TaskbarAl' 0 Set-RegValue $adv 'ShowTaskViewButton' 0 Set-RegValue $adv 'LaunchTo' 1 Set-RegValue $adv 'Start_TrackProgs' 0 $theme = "$base\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" Set-RegValue $theme 'AppsUseLightTheme' 0 Set-RegValue $theme 'SystemUseLightTheme' 0 $search = "$base\Software\Microsoft\Windows\CurrentVersion\Search" Set-RegValue $search 'SearchboxTaskbarMode' 0 # SearchSettings 在某些 build 上 reg.exe 會「存取被拒」(Win11Debloat 的 # Disable_Search_History.reg 跟 Disable_Search_Highlights.reg 都會撞), # 但 PowerShell .NET API 寫得進去——這裡一次處理掉,Win11Debloat config 已把這兩項移除 $searchSettings = "$base\Software\Microsoft\Windows\CurrentVersion\SearchSettings" Set-RegValue $searchSettings 'IsDeviceSearchHistoryEnabled' 0 Set-RegValue $searchSettings 'IsDynamicSearchBoxEnabled' 0 $cloud = "$base\Software\Policies\Microsoft\Windows\CloudContent" Set-RegValue $cloud 'DisableSpotlightCollectionOnDesktop' 1 Set-RegValue $cloud 'DisableWindowsSpotlightFeatures' 1 # 鍵盤排序:英文鍵盤排第一(預設英數),注音排第二 $kbPre = "$base\Keyboard Layout\Preload" Set-RegValue $kbPre '1' '00000409' 'String' Set-RegValue $kbPre '2' '00000404' 'String' # CHT 注音:預設英數模式、關掉雲端候選與預測 $cht = "$base\Software\Microsoft\InputMethod\Settings\CHT" Set-RegValue $cht 'Enable Default Input Mode' 0 Set-RegValue $cht 'Enable Cand Predict' 0 Set-RegValue $cht 'Enable Cloud Cand' 0 Set-RegValue $cht 'Enable Cloud Input' 0 # 把系統 Hotkey 切換鍵停掉(3 = 不指定鍵) $tg = "$base\Keyboard Layout\Toggle" Set-RegValue $tg 'Hotkey' '3' 'String' Set-RegValue $tg 'Language Hotkey' '3' 'String' Set-RegValue $tg 'Layout Hotkey' '3' 'String' } Section 'apply-ui-ime-default-profile' { # (a) Default profile(新使用者首次登入會繼承) $hivePath = 'C:\Users\Default\NTUSER.DAT' $mountKey = 'HKU\SetupDefault' reg.exe load $mountKey $hivePath | Out-Null try { Apply-UiImeSettings "Registry::$mountKey" Log "Applied to Default profile" } finally { [GC]::Collect() Start-Sleep 1 reg.exe unload $mountKey | Out-Null } # (b) 已載入的真人 user hive(HKU\,跳過 .DEFAULT / 系統 SID) # 取自 Win32_UserProfile,過濾 Special;只在 hive 已載入時寫 $profiles = Get-CimInstance Win32_UserProfile -ErrorAction SilentlyContinue | Where-Object { -not $_.Special } foreach ($p in $profiles) { $sid = $p.SID if (Test-Path "Registry::HKEY_USERS\$sid") { Apply-UiImeSettings "Registry::HKEY_USERS\$sid" Log ("Applied to live user hive {0} ({1})" -f $sid, (Split-Path $p.LocalPath -Leaf)) } else { Log ("Skip {0} ({1}) - hive not loaded" -f $sid, (Split-Path $p.LocalPath -Leaf)) } } }