Skip to content

Instantly share code, notes, and snippets.

View alan23273850's full-sized avatar

Wei-Lun Tsai alan23273850

  • Academia Sinica
  • Taipei, Taiwan
View GitHub Profile
@alan23273850
alan23273850 / AutoEnableMobileHotspot.ps1
Last active June 21, 2025 09:48 — forked from datio/enable-wifi.ps1
Enable Windows 10 & 11 WiFi Hotspot - Powershell Script
$intervalSeconds = 5
while ($true) {
# 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)