-
Notifications
You must be signed in to change notification settings - Fork 3
/
VRHotSpot.ps1
77 lines (58 loc) · 2.76 KB
/
VRHotSpot.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
$wifiInterfaceName="WiFi" # run "netsh wlan show interfaces" to get list of your interfaces
$wifiProfile="McAronNet_5G" # usually the same as your network SSID. To get list of profiles run "netsh wlan show profiles"
$virtualDesktopProcessName="VirtualDesktop.Streamer"
$ErrorActionPreference = "Stop"
$connectionProfile = [Windows.Networking.Connectivity.NetworkInformation,Windows.Networking.Connectivity,ContentType=WindowsRuntime]::GetInternetConnectionProfile()
$tetheringManager = [Windows.Networking.NetworkOperators.NetworkOperatorTetheringManager,Windows.Networking.NetworkOperators,ContentType=WindowsRuntime]::CreateFromConnectionProfile($connectionProfile)
if ((netsh wlan show autoconfig | Select-String -CaseSensitive "disabled on interface `"$wifiInterfaceName`"")){
echo "Starting configuration revert..."
echo "enabling autoconfig on wifi interface"
netsh wlan set autoconfig enabled=yes interface="$wifiInterfaceName"
if ($tetheringManager.TetheringOperationalState -ne 'Off'){
echo "Turning off HotSpot"
($tetheringManager.StopTetheringAsync()) > $null
}
read-host "Configuration revert complete! Press ENTER to exit..."
exit
}
echo "Starting wifi configuration..."
echo "enabling autoconfig on wifi interface"
netsh wlan set autoconfig enabled=yes interface="$wifiInterfaceName"
netsh wlan connect name="$wifiProfile" interface="$wifiInterfaceName"
echo "Connecting to wifi"
while(-not (netsh interface show interface | Select-String -CaseSensitive "Connected.+$wifiInterfaceName"))
{
Start-Sleep -Seconds 1
echo "Waiting for connection..."
}
echo "Starting Hotspot with half speed (client and hotspot simultaneously)"
($tetheringManager.StartTetheringAsync()) > $null
while($tetheringManager.TetheringOperationalState -ne 'On')
{
echo "Waiting for HotSpot start..."
Start-Sleep -Seconds 1
}
($tetheringManager.StopTetheringAsync()) > $null
echo "Disconnecting wifi"
netsh wlan disconnect interface="$wifiInterfaceName"
echo "Starting Hotspot with full speed"
($tetheringManager.StartTetheringAsync()) > $null
while($tetheringManager.TetheringOperationalState -ne 'On' )
{
echo "Waiting for HotSpot start..."
Start-Sleep -Seconds 1
}
try {
$virtualDesktopPath=Get-Process -Name "$virtualDesktopProcessName" | Select -ExpandProperty Path
echo "stopping VirtualDesktop"
Stop-Process -Name "$virtualDesktopProcessName" -Force
echo "starting VirtualDesktop"
Start-Process -FilePath "$virtualDesktopPath"
}
catch {
echo "VirtualDesktop is not running"
}
echo "disabling autoconfig on wifi interface"
netsh wlan set autoconfig enabled=no interface="$wifiInterfaceName"
echo "Complete! Run this script again to revert configuration."
read-host "Press ENTER to exit..."