通过cmd/batch/powershell启用Win10内置热点 [英] enable Win10 inbuild hotspot by cmd/batch/powershell

查看:925
本文介绍了通过cmd/batch/powershell启用Win10内置热点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种通过命令提示符/powershell/批处理文件在Win10中启用/禁用内置Hotspot的方法.在GUI中,可以使用网络面板中的第三个按钮轻松完成此操作(请参见下图),但我想使其自动化.

as the title says I search for a way to enable/disable the Hotspot inbuild in Win10 via the command prompt/powershell/a batch file. In the GUI it can be easily done with the third button in the network panel (see image below), but I want to automate it.

我已经找到了数百篇有关如何通过netsh 创建新热点的教程,但是据我了解,这将创建另一个不同的热点. 相反,我想使用已经配置的.还是Win10都一样并且每次都会创建一个新的热点,但是只是在内存之间设置了?

I already found some hundred tutorials how to create a new hotspot via netsh, but as I understand it this would create another, different hotspot. Instead I want to use the already configured one. Or does Win10 the same and everytime creates a new hotspot but in between only memories the settings?

预先感谢

塞巴斯蒂安

我玩了一会儿,发现了以下内容:

I played around a little bit and discovered the following:

  1. 我当前的WiFi驱动程序不支持托管网络.如果输入netsh wlan show drivers,它会显示hosted network supprt: no.因此,对于通用"解决方案,我将不得不更新驱动程序.
  2. 尽管如此,我仍可以使用内置解决方案创建一个HotSpot(见图).
  3. 看来,如果我激活此HotSpot窗口,则会创建一个附加的Microsoft Wi-Fi Direct Virtual Adapter #x.一旦停用HotSpot,适配器就会消失.
  1. my current WiFi driver doesnt support hosted networks. If I enter netsh wlan show drivers it says hosted network supprt: no. So for the 'common' solution I would had to update the driver.
  2. nevertheless I can create a HotSpot with the inbuild solution (see image).
  3. it seems that if I activate this HotSpot windows creates an additional Microsoft Wi-Fi Direct Virtual Adapter #x. As soon I deactivate the HotSpot, the adapter vanishes.

因此,看来MS对内置热点使用的是与netsh变体完全不同的技术.这又使我想到了一个问题:如何通过脚本自动启用/禁用此热点?

So it seems that MS is using a very different technique for the inbuild hotspot than the netsh variant. Which brings me again to the question: how can I automate (by script) the enabling/disabling of this hotspot?

推荐答案

托管网络(可以使用netsh wlan set hostednetwork ...命令进行配置)和新"移动热点在后台使用不同的技术.

The Hosted Network (which can be configured using the netsh wlan set hostednetwork ... command) and the "new" Mobile Hotspot use different technologies under the hood.

有一个WinRT API可以控制和配置您所指的新"移动热点.您可以从PowerShell调用它:

There's a WinRT API to control and configure the "new" mobile hotspot you're referring to. You can call it from PowerShell:

以下代码段需要 Ben N.在PowerShell中用于IAsyncOperation和IAsyncAction的await函数,可在此处找到.

$connectionProfile = [Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentType=WindowsRuntime]::GetInternetConnectionProfile()
$tetheringManager = [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentType=WindowsRuntime]::CreateFromConnectionProfile($connectionProfile)

# Be sure to include Ben N.'s await for IAsyncOperation:
# https://superuser.com/questions/1341997/using-a-uwp-api-namespace-in-powershell

# Check whether Mobile Hotspot is enabled
$tetheringManager.TetheringOperationalState

# Start Mobile Hotspot
Await ($tetheringManager.StartTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult])

# Stop Mobile Hotspot
Await ($tetheringManager.StopTetheringAsync()) ([Windows.Networking.NetworkOperators.NetworkOperatorTetheringOperationResult])

NetworkOperatorTetheringManager 类还允许您以编程方式设置SSID和热点的密码.

The NetworkOperatorTetheringManager class also allows you to set the SSID and the passphrase of your hotspot programmatically.

这篇关于通过cmd/batch/powershell启用Win10内置热点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆