网上有很多开启热点的方法,并不是都好使,这种方法亲测可用,仅此记录
1、使用cmd的管理员模式执行命令
set-executionpolicy remotesigned
2、打开任意一个文件夹,在地址栏里输入
%appdata%\Microsoft\Windows\Start Menu\Programs\Startup
3、打开的文件夹中,空白处,点击【右键】,在打开的菜单项中,选择【新建文本文档】;如果可以请使用editplus或者使用其他编辑器,尽量不要使用txt编辑器
powershell -executionpolicy remotesigned -file "%appdata%\Microsoft\Windows\Start Menu\Programs\pondsihotspot.ps1"
exit
4、用txt打开文件,另存为。另存为窗口,注意两个地方:1)文件名填入以【.bat】结尾的名称,保存类型选择【所有文件】2)编码选择【ANSI】最后点击【保存】。
5、再打开文件资源管理器,并在地址栏输入:
%appdata%\Microsoft\Windows\Start Menu\Programs
6、打开的文件夹中,空白处,点击【右键】,在打开的菜单项中,选择【新建文本文档】;
7、使用3相同的方法再文件中写入
Add-Type -AssemblyName System.Runtime.WindowsRuntime
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0]
Function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.Wait(-1) | Out-Null
$netTask.Result
}
Function AwaitAction($WinRtAction) {
$asTask = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and !$_.IsGenericMethod })[0]
$netTask = $asTask.Invoke($null, @($WinRtAction))
$netTask.Wait(-1) | Out-Null
}
$connectionProfile = [Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentType=WindowsRuntime]::GetInternetConnectionProfile()
$tetheringManager = [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentType=WindowsRuntime]::CreateFromConnectionProfile($connectionProfile)
if ($tetheringManager.TetheringOperationalState -eq 1) {
"Hotspot is already On!"
}
else{
"Hotspot is off! Turning it on"
Await ($tetheringManager.StartTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult])
}
8、保存后用文本打开并另存为,另存为窗口,注意两个地方:
1)文件名填入以【.ps1】结尾的名称,保存类型选择【所有文件】
2)编码选择【ANSI】最后点击【保存】。
9、最后运行【wifi.bat】,测试能否打开热点。再重启测试。