馬上加入Android 台灣中文網,立即免費下載應用遊戲。
您需要 登錄 才可以下載或查看,沒有帳號?註冊
x
本帖最後由 qciwbu95 於 2025-10-30 21:57 編輯
一鍵 Enter 切換 Windows 11 深色、淺色模式!用 PowerShell 腳本輕鬆實現
隨著 Windows 11 的 UI 美學進化,使用者越來越注重主題風格的切換。
無論是夜間護眼的「深色模式」,還是日間清爽的「淺色模式」,
其實都可以透過 PowerShell 一行命令自動切換,不必再進入設定頁面手動調整。
以下提供的 PowerShell 腳本的功能是:
讀取目前的「應用程式」與「系統」主題設定 (深色或淺色) → 將兩者切換為相反模式 →
寫入新註冊值 → 重新啟動 Windows Explorer 立即套用變更 → 顯示目前切換後的模式。
- # 讀取目前主題設定
- $appTheme = Get-ItemPropertyValue -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme
- $sysTheme = Get-ItemPropertyValue -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme
- # 計算相反值
- $newApp = if ($appTheme -eq 1) {0} else {1}
- $newSys = if ($sysTheme -eq 1) {0} else {1}
- # 寫入新的主題設定
- Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Value $newApp
- Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -Value $newSys
- # 重啟 Windows Explorer 讓設定立即生效
- Stop-Process -ProcessName explorer -Force
- Start-Process explorer
- Write-Host "已切換到" ($(if ($newApp -eq 1) {'淺色'} else {'深色'}) + "模式。")
複製代碼
▼ 適用版本
- Windows 10 1903(2019 年 5 月)起
- Windows 11 所有版本(21H2、22H2、23H2 等)
這段腳本適用於 Windows 10 1903 版以後 以及 所有 Windows 11 版本,
因為這些版本開始支援獨立設定「應用程式」與「系統」的主題模式,並將其儲存在註冊表的 HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize 路徑下。
|

|