前言
win10在使用宽带连接拨号上网时,移动热点功能是灰色的,无法正常开启热点分享网络。主要有两种方法可以开启热点。
- 电脑先连接上一个WiFi,开启移动热点,接着断开WiFi,移动热点还是打开状态;win+R 输入
ncpa.cpl 打开 “网络连接” ,右键单击拨号上网的那个连接(现在应该只有这个有网络),选择 “属性” ,选择 “共享” ,勾选 “允许其它网络用户通过此计算机的 Internet 连接来连接(N)” ,下方的 “家庭网络连接(H)” 下拉列表中选择之前打开移动热点时新出现的连接,通常来说是 “本地连接* 一个数字” 的名字格式(不一定是这个,看一下开启热点新增的那个连接名字最靠谱),点击 “确定” ,大功告成!现在尝试用手机连上热点就能上网了。
- 使用第三方软件。比如:MyPublicWiFi (https://mypublicwifi.com/publicwifi/ch/index.html) 。安装后,先改成中文界面;在设置中将 “首选 WiFi 技术” 改为 “Moblie HotSpot” (不改的话可能热点无法正常上网),保存更改;首页开启热点就行了。
在使用第三方软件时,可能会影响网络,所以我还是改为了使用第一种不安装第三方软件的方法。但是,需要手机先开启热点仍然是一个头疼的步骤。所以,我借助了 AI 写了个 PowerShell 脚本来实现:在无网络的情况下,强制开启移动热点。
使用方法
脚本如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
$tetheringManagerType = [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager, Windows.Networking.NetworkOperators, ContentType=WindowsRuntime]
$networkInfoType = [Windows.Networking.Connectivity.NetworkInformation, Windows.Networking.Connectivity, ContentType=WindowsRuntime]
Write-Host "正在强制激活热点服务..." -ForegroundColor Cyan Write-Host ""
Write-Host "步骤1: 获取当前网络连接配置..." -ForegroundColor Gray
$profiles = $networkInfoType::GetConnectionProfiles()
$profile = $profiles | Where-Object { $_.IsWlanConnectionProfile } | Select-Object -First 1
if ($null -eq $profile) { Write-Host "未找到Wi-Fi连接,将使用第一个可用连接..." -ForegroundColor Yellow $profile = $profiles[0] }
Write-Host "已选择连接配置" -ForegroundColor Gray
Write-Host "" Write-Host "步骤2: 创建热点管理器并启动热点..." -ForegroundColor Gray
$tetheringManager = $tetheringManagerType::CreateFromConnectionProfile($profile)
$null = $tetheringManager.StartTetheringAsync()
Write-Host "指令已发送,正在检测硬件响应..." -ForegroundColor Yellow Write-Host ""
Write-Host "步骤3: 检测热点启动状态..." -ForegroundColor Gray Write-Host "正在等待网络适配器响应" -ForegroundColor Gray
$isSuccess = $false
for ($i = 1; $i -le 10; $i++) { Write-Host "." -NoNewline Start-Sleep -Seconds 1 $virtualAdapter = Get-NetAdapter | Where-Object { $_.InterfaceDescription -like "*Wi-Fi Direct Virtual*" -and $_.Status -eq "Up" } if ($virtualAdapter) { $isSuccess = $true Write-Host " 找到适配器!" -ForegroundColor Green break } }
Write-Host ""
if ($isSuccess) { Write-Host "====================================" -ForegroundColor Green Write-Host "判断结果:热点启动成功!" -ForegroundColor Green Write-Host "检测到活动适配器: $($virtualAdapter.Name)" -ForegroundColor Gray Write-Host "====================================" -ForegroundColor Green Write-Host "" Write-Host "重要提示:" -ForegroundColor Yellow Write-Host "热点已创建,但还需要配置网络共享才能让其他设备上网:" -ForegroundColor Cyan Write-Host "" Write-Host "操作步骤:" -ForegroundColor White Write-Host "1. 按 Win+R 打开运行对话框" -ForegroundColor Gray Write-Host "2. 输入 'ncpa.cpl' 并按回车打开网络连接" -ForegroundColor Gray Write-Host "3. 找到您上网的宽带连接(如以太网)" -ForegroundColor Gray Write-Host "4. 右键 -> 属性 -> 共享选项卡" -ForegroundColor Gray Write-Host "5. 勾选'允许其他网络用户...'" -ForegroundColor Gray Write-Host "6. 选择 '$($virtualAdapter.Name)' 这个适配器" -ForegroundColor Gray Write-Host "7. 点击确定保存设置" -ForegroundColor Gray } else { Write-Host "====================================" -ForegroundColor Red Write-Host "判断结果:热点启动可能失败。" -ForegroundColor Red Write-Host "====================================" -ForegroundColor Red Write-Host "" Write-Host "可能的原因和解决方法:" -ForegroundColor Yellow Write-Host "1. 请确保计算机的 Wi-Fi 功能已手动打开" -ForegroundColor Gray Write-Host "2. 检查是否有其他程序占用了无线网卡(如虚拟机软件)" -ForegroundColor Gray Write-Host "3. 尝试在系统设置中手动开启移动热点" -ForegroundColor Gray Write-Host "4. 重启计算机后重试" -ForegroundColor Gray Write-Host "5. 确保无线网卡驱动是最新版" -ForegroundColor Gray Write-Host "" Write-Host "注意:即使这里显示失败,热点可能仍在后台启动中" -ForegroundColor Magenta Write-Host "可以查看系统托盘或系统设置确认热点状态" -ForegroundColor Magenta }
Write-Host "" Write-Host "脚本执行完成" -ForegroundColor Cyan
pause
|
先新建一个 txt 文件,命名为:~无网络强制启动热点 (名字随意),记事本打开,将上述代码复制进去,保存,在记事本菜单栏的 “文件” 里选择 “另存为…” ,编码 改成 “ANSI” (确保中文不乱码),保存。重命名该文件后缀,由 ~无网络强制启动热点.txt 改为 ~无网络强制启动热点.ps1 。右键该文件,选择 “使用 PowerShell 运行” 即可。
如果出现报错,建议将报错信息复制,询问AI。
附加
- 如果使用第三方软件后,没有正常退出或者其它原因导致网络不正常,可以尝试在 “网络连接” 中右键 “以太网” -> “属性” -> “网络” -> “此连接使用下列项目” -> “Internet 协议版本 4 (TCP/IPv4)” -> “常规” -> 勾选 “自动获得 IP 地址” 。(此方法不一定有效,如果不行建议询问AI或网络搜索解决办法)