最后活跃于 1758113074

fallrain 修订了这个 Gist 1758113074. 跳至此修订

1 file changed, 37 insertions

windows-conf.md(file created)

@@ -0,0 +1,37 @@
1 + 下面是一个 PowerShell 脚本,可以满足你的需求:
2 +
3 + 1. 设置硬件时钟为 UTC;
4 + 2. 关闭 Windows 时间自动同步(包括网络时间和自动设置时间);
5 + 3. 手动与 NTP 服务器同步一次;
6 + 4. 关闭“快速启动”。
7 +
8 + 你可以将下面的内容保存为 `setup.ps1`,右键用管理员身份运行 PowerShell,然后执行此脚本。
9 +
10 + ```powershell
11 + # 1. 设置硬件时钟为 UTC
12 + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" -Name "RealTimeIsUniversal" -Value 1
13 +
14 + # 2. 关闭 Windows 自动时间同步
15 + Set-Service -Name w32time -StartupType Disabled
16 + Stop-Service -Name w32time
17 +
18 + # 3. 手动与 NTP 服务器同步一次
19 + Set-Service -Name w32time -StartupType Manual
20 + Start-Service -Name w32time
21 + w32tm /resync
22 +
23 + # 4. 关闭快速启动
24 + $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power"
25 + Set-ItemProperty -Path $regPath -Name "HiberbootEnabled" -Value 0
26 +
27 + Write-Host "全部设置完成,请重启电脑以生效。"
28 + ```
29 +
30 + **注意事项:**
31 + - 需要以管理员权限运行 PowerShell。
32 + - 第 1 步设置后,Windows 与 Linux 双系统可以共享 UTC 硬件时间。
33 + - 第 2 步关闭了自动时间同步,如需恢复可将 `w32time` 服务设置为自动并启动。
34 + - 第 3 步会手动与默认 NTP 服务器同步一次时间。
35 + - 第 4 步关闭了快速启动,重启后生效。
36 +
37 + 如有需要调整 NTP 服务器,可在 `w32tm /config /manualpeerlist:"ntp.example.com" /update` 里更换服务器地址。
更新 更早