
管理员打开CMD窗口::开启移动热点CMD 管理员cmdpowershell -Command { Add-Type -AssemblyName System.Runtime.WindowsRuntime; $connectionProfile [Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentTypeWindowsRuntime]::GetInternetConnectionProfile(); $tetheringManager [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentTypeWindowsRuntime]::CreateFromConnectionProfile($connectionProfile); if ($tetheringManager.TetheringOperationalState -ne 1) { $asyncOp $tetheringManager.StartTetheringAsync(); $asyncOp.GetResults(); Write-Host 热点已开启 } else { Write-Host 热点已经是开启状态 } }::❌ 关闭移动热点CMD 管理员cmdpowershell -Command { Add-Type -AssemblyName System.Runtime.WindowsRuntime; $connectionProfile [Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentTypeWindowsRuntime]::GetInternetConnectionProfile(); $tetheringManager [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentTypeWindowsRuntime]::CreateFromConnectionProfile($connectionProfile); if ($tetheringManager.TetheringOperationalState -eq 1) { $asyncOp $tetheringManager.StopTetheringAsync(); $asyncOp.GetResults(); Write-Host 热点已关闭 } else { Write-Host 热点已经是关闭状态 } }:: 查询移动热点状态cmdpowershell -Command { Add-Type -AssemblyName System.Runtime.WindowsRuntime; $connectionProfile [Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentTypeWindowsRuntime]::GetInternetConnectionProfile(); $tetheringManager [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentTypeWindowsRuntime]::CreateFromConnectionProfile($connectionProfile); $state $tetheringManager.TetheringOperationalState; if ($state -eq 1) { 开启 } elseif ($state -eq 0) { 关闭 } else { 正在切换 } }