修复每次重启后 “Internet 连接共享” 失效

前言

此前设置了 iPad 和 Windows PC 之间的有线网络共享,但 PC 每次重启后共享都需要重新设置,因此在互联网上检索了以下解决方案。

解决方案

https://stackoverflow.com/questions/17656231/how-to-enable-internet-connection-sharing-using-command-line

  • 在注册表 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedAccess 新建一个 REG_DWORDEnableRebootPersistConnection,并修改值为 1

  • 在任务计划程序中新建一个任何用户登录时延迟 1 分钟启动的任务,使用最高权限运行 cmd /c PowerShell.exe "Restart-Service SharedAccess",在每次重启 PC 后重启 ICS 服务。

原文参考

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# fix Windows 10 ICS not working after reboot
# https://support.microsoft.com/en-us/help/4055559/ics-doesn-t-work-after-computer-or-service-restart-on-windows-10
[microsoft.win32.registry]::SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedAccess", "EnableRebootPersistConnection", 0x01)

# Enable IP Forwarding
# https://serverfault.com/questions/929081/how-can-i-enable-packet-forwarding-on-windows/929089#929089
Set-NetIPInterface -Forwarding Enabled
# Check IP Forwarding Status
Get-NetIPInterface | Select-Object ifIndex,InterfaceAlias,AddressFamily,ConnectionState,Forwarding | Sort-Object -Property IfIndex | Format-Table

# Change the Internet Connection Sharing (ICS) service Startup type to Automatic.
Set-Service SharedAccess -StartupType Automatic
# Start ICS service for now
Start-Service SharedAccess
# Check ICS service Status
Get-Service SharedAccess
Licensed under CC BY-NC-SA 4.0
京ICP备17016743号
Built with Hugo
主题 StackJimmy 设计