Last active
June 21, 2025 22:08
-
-
Save datio/e78649083f238b779f0a68526c191dda to your computer and use it in GitHub Desktop.
Enable Windows 10 & 11 WiFi Hotspot - Powershell Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]) |
Not work.
Exeption in call "CreateFromConnectionProfile"
Many thanks to your script! I've modified the script to restart the Hotspot every 5 seconds if it is not turned on. It is very helpful for sharing the Ethernet to my smartphone. The periodic check is due to my poor constantly disconnecting Ethernet.
Not work. Exeption in call "CreateFromConnectionProfile"
@Yoda49
Is it due to the administrator privilege?
I apologize I'm much too busy to help you but you could just paste all that
code into chat GPT and it'll help you with it it's kind of a good habit to
get into just make sure to give it really really detailed responses about
you know your operating system setup and what you intend and your wi fi
names and everything tell it what operating system you're on everything you
could think of
…On Sat, Jun 21, 2025 at 2:49 AM Wei-Lun Tsai ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Not work. Exeption in call "CreateFromConnectionProfile"
@Yoda49 <https://github.com/Yoda49>
Is it due to the administrator privilege?
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/datio/e78649083f238b779f0a68526c191dda#gistcomment-5625921>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWFQGILNWGGZ4I2SS5WJMYD3EUTBRBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTANRZGQZDQNJQU52HE2LHM5SXFJTDOJSWC5DF>
.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Isn't GPT 4 awesome I just made all this in fifteen minutes