-
-
Save datio/e78649083f238b779f0a68526c191dda to your computer and use it in GitHub Desktop.
# https://stackoverflow.com/questions/45833873/enable-win10-inbuild-hotspot-by-cmd-batch-powershell/60444585#answer-60444585 | |
[Windows.System.UserProfile.LockScreen,Windows.System.UserProfile,ContentType=WindowsRuntime] | Out-Null | |
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 | |
} | |
# https://stackoverflow.com/a/55563418 | |
$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]) |
could you update this for Windows eleven
Ohh never mind you don't need to it just works right off the bat you should rename this to keep it up to date and thank you very very much for how easy you made this this is 1 of the smartest things I have ever seen is putting real windows batch file functionality and Powershell file functionality on Github so everybody could get it that's really really smart
@mjoe67886 Thanks and I'm glad it still works! Just had the title changed as per your suggestion.
I stopped using this script at my previous job as the USB WiFi dongle connectivity broke because of a Windows update.
It might had been an issue with the specific chipset of that specific dongle but I remember reading articles about a more generic problem, so keep that in mind as it could happen again.
The issue was fixed after 2-3 weeks via another Windows update, but in the meantime I simply plugged in a cheap Wifi repeater like the TP-LINK ones below and called it a day.
Thanks I really appreciate it I just made a batch file that automatically keeps my wifi and my hotspot enabled out of it it checks every 5 seconds and I run it at startup with task scheduler.. So all my devices now have strong Internet my T V my iphone everything... You probably don't need it but if you want it I'll send it you could even put it up here so everybody can grab that too so they have strong Internet for all their devices...
Isn't GPT 4 awesome I just made all this in fifteen minutes
Not work.
Exeption in call "CreateFromConnectionProfile"
useful thanks you