WINDOWS 六月 08, 2025

【转】如何开机自动开启移动热点

文章字数 4.9k 阅读约需 4 mins. 阅读次数

当我们经常需要使用移动热点的时候,可能希望开机便自启动移动热点。

一、 技术难度:★★★(3颗星)

阅读时间:大约3分钟

适用于:Windows10/11

二、执行步骤:

1、鼠标右击屏幕左下角的开始菜单,打开 Windows PowerShell(管理员)(A)

在Windows11中可以打开 Windows终端(管理员)(A)

start

2、在打开的Windows PowerShell窗口中输入:

set-executionpolicy remotesigned

按下键盘上的回车键(Enter按键)。

set-executionpolicy

3、等待一会,将出现如下的提示。输入:a。然后按下回车键(Enter按键)。

(Windows11的终端中可能不显示提示,这是正常的。)

set-executionpolicy-confirm

4、关闭Windows PowerShell窗口。

打开资源管理器,并在地址栏输入:

%appdata%\Microsoft\Windows\Start Menu\Programs\Startup

然后按下回车键(Enter按键)。

startup

5、将进入“启动”这个文件夹内。在空白处鼠标右击,选择“新建”,选择“文本文档”。

new-text-document

6、更改新建的这个文件的txt后缀为bat

change-txt-to-bat

7、若是出现下图提示,点击“”。

change-txt-to-bat-confirm

8、鼠标右键点击该文件,然后选择“编辑”。

edit-bat-file

9、在打开的窗口粘贴以下内容,然后保存并关闭这个bat文件。

powershell -executionpolicy remotesigned -file "%appdata%\Microsoft\Windows\Start Menu\Programs\pondsihotspot.ps1"
exit

edit-bat-file-content

10、在资源管理器的地址栏输入:

%appdata%\Microsoft\Windows\Start Menu\Programs

然后按下回车键(Enter按键),将进入“程序”这个文件夹内。

在空白处鼠标右击,选择“新建”,选择“文本文档”。

更改新建的这个文件名字为“pondsihotspot.ps1”。

若是出现重命名提示,点击“”。

new-ps1-file

11、鼠标右键点击该文件,选择“打开方式”,选择“记事本”打开。

edit-ps1-file

12、复制以下内容到文件内,完成后保存并关闭。

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) { 
    "" 
} 
else{ 
    Await ($tetheringManager.StartTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult]) 
}

edit-ps1-file-content

10、重启电脑,看下是否可以自动打开移动热点。

三、以上。

0%