告别手动开启热点,开机静默运行,断线自动巡检重连。
适合所有用户。自动完成目录创建、核心脚本生成、注册表自启项写入,并在后台自动拉起热点服务。
irm https://yourdomain.pages.dev/install.ps1 | iex
如果不再需要自动开热点,以管理员身份运行下方命令即可彻底无痕清除:
irm https://yourdomain.pages.dev/uninstall.ps1 | iex
如果你更喜欢自己动手控制细节,或者网络无法远程拉取脚本,可按照以下步骤手动配置。
在 PowerShell(管理员) 中运行以下命令,自动在系统目录创建空脚本:
New-Item -ItemType Directory -Path "C:\Program Files\HotspotService" -Force; New-Item -ItemType File -Path "C:\Program Files\HotspotService\hotspot.ps1" -Force
用记事本打开 C:\Program Files\HotspotService\hotspot.ps1,将下方完整代码复制进去并保存关闭:
$logFile = "C:\Program Files\HotspotService\log.txt"
# Clear old log on startup
Remove-Item -Path $logFile -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 15
function Write-Log($message) {
$time = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
"[$time] $message" | Out-File $logFile -Append -Encoding ascii
}
Write-Log "=== Hotspot Keep-Alive Heartbeat Service Started ==="
try {
$netType = [Windows.Networking.Connectivity.NetworkInformation, Windows.Networking.Connectivity, ContentType=WindowsRuntime]
$pickerType = [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager, Windows.Networking.NetworkOperators, ContentType=WindowsRuntime]
} catch {
Write-Log "[FATAL] Failed to load WinRT libraries: $_"
}
while ($true) {
try {
$profile = $netType::GetInternetConnectionProfile()
if ($null -ne $profile) {
$manager = $pickerType::CreateFromConnectionProfile($profile)
$manager.StartTetheringAsync() | Out-Null
Write-Log "Heartbeat: Tethering activation enforced successfully."
} else {
Write-Log "[WARNING] Internet profile is null. Waiting..."
}
} catch {
Write-Log "[ERROR] Loop exception: $_"
}
Start-Sleep -Seconds 180
}
继续在 PowerShell(管理员) 中执行以下完整代码,生成后台 VBS 引导壳并配置注册表:
# 生成 launch.vbs 隐藏运行窗口
$vbsContent = @'
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "powershell.exe -NoProfile -ExecutionPolicy Bypass -File ""C:\Program Files\HotspotService\hotspot.ps1""", 0, False
'@
$vbsContent | Out-File "C:\Program Files\HotspotService\launch.vbs" -Encoding ascii
# 写入注册表自启项
Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "AutoHotspot" -Value 'wscript.exe "C:\Program Files\HotspotService\launch.vbs"'
Write-Host ">>> 手动配置完成!你可以重启电脑测试了。<<<" -ForegroundColor Green
测试过程中如果遇到系统权限限制或进程问题,可使用以下常用排查命令:
cmd /c taskkill /f /im powershell.exe /im wscript.exe
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force