Last active
June 9, 2019 23:18
-
-
Save lg/8ed7fe391acca6fc7b368f25c2dda56e to your computer and use it in GitHub Desktop.
CloudyGamer initialization script (run manually up to each ###### line)
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
# CloudyGamer | |
# | |
# CURRENTLY WRITTEN FOR PAPERSPACE (see link above for additional azure/aws items) | |
# based off of: https://github.com/lg/cloudy-gamer/blob/master/cloudygamer.psm1 | |
# | |
# troubleshooting: | |
# 1. latency spikes: | |
# - if hooked up to an external monitor, disconnect | |
# - if on wifi, try wired | |
# - if wired and on a fancy switch, turn on/off congestion control on the port | |
# - try with/without vpn (ex zerotier), steam will sometimes try to relay you | |
# - ensure you've enabled hardware encoding/decoding on the server/client | |
# - disable location services on macos | |
# - try bringing down the resolution in game | |
# - if monitor, turn off retina and bring res down to save usbc bandwidth | |
# - make sure you did the stuff below (i.e. turn off: firewall, ipv6, | |
# windows updates, windows defender, default video card, etc) | |
# 2. no audio: | |
# - start a game on steam via streaming so it'll install the necessary audio driver | |
######################################## | |
# disable uac | |
New-ItemProperty -Path "HKLM:Software\Microsoft\Windows\CurrentVersion\policies\system" -Name EnableLUA -PropertyType DWord -Value 0 -Force | |
Restart-Computer -Force | |
######################################## | |
# initial init | |
New-Item -ItemType directory -Path "c:\cloudygamer\downloads" -Force | |
# replace command prompt with powershell and stop server manager if it exists | |
Get-ScheduledTask -TaskName ServerManager -ErrorAction SilentlyContinue | Disable-ScheduledTask -Verbose | |
Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" "DontUsePowerShellOnWinX" -Value 0 | |
# install steam first since windows updates will take forever (and you can install games) | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
(New-Object System.Net.WebClient).DownloadFile("https://steamcdn-a.akamaihd.net/client/installer/SteamSetup.exe", "c:\cloudygamer\downloads\steamsetup.exe") | |
& "c:\cloudygamer\downloads\steamsetup.exe" /S | Out-Null | |
& "C:\Program Files (x86)\Steam\Steam.exe" # interactive | |
######################################## | |
# disable Windows Update | |
Set-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\WindowsUpdate\AU" "NoAutoUpdate" 1 | |
Set-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\WindowsUpdate\AU" "AUOptions" 2 | |
# install windows update automation and run it (will take 1-2 hours) | |
Install-PackageProvider -Name NuGet -Force | |
Install-Module PSWindowsUpdate -Force | |
Add-WUServiceManager -ServiceID 7971f918-a847-4430-9279-4a52d1efe18d -Confirm:$false | |
# this step might need to be run a few times between reboots | |
Get-WUInstall -MicrosoftUpdate -AcceptAll -IgnoreReboot -Install -Verbose | |
Restart-Computer -Force | |
######################################## | |
# disable windows defender | |
Set-MpPreference -DisableRealtimeMonitoring $true | |
Restart-Computer -Force | |
######################################## | |
# finish disabling windows defender | |
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\WdBoot" -Name Start -Value 4 | |
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\WdFilter" -Name Start -Value 4 | |
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\WdNisDrv" -Name Start -Value 4 | |
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\WdNisSvc" -Name Start -Value 4 | |
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\WinDefend" -Name Start -Value 4 | |
Disable-ScheduledTask -TaskName 'Windows Defender Cleanup' -TaskPath '\Microsoft\Windows\Windows Defender' | |
Disable-ScheduledTask -TaskName 'Windows Defender Scheduled Scan' -TaskPath '\Microsoft\Windows\Windows Defender' | |
Disable-ScheduledTask -TaskName 'Windows Defender Verification' -TaskPath '\Microsoft\Windows\Windows Defender' | |
Disable-ScheduledTask -TaskName 'Windows Defender Cache Maintenance' -TaskPath '\Microsoft\Windows\Windows Defender' | |
# disable ipv6 | |
Set-Net6to4Configuration -State disabled | |
Set-NetTeredoConfiguration -Type disabled | |
Set-NetIsatapConfiguration -State disabled | |
# turn off ie security | |
$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" | |
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" | |
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 | |
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 | |
# firewall off (off for now, shouldnt be needed) | |
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False | |
# priority to programs, not background | |
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\PriorityControl" -Name "Win32PrioritySeparation" -Value 38 | |
# explorer set to performance | |
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" -Name "VisualFXSetting" -Value 2 | |
# disable crash dump | |
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" -Name "CrashDumpEnabled" -Value 0 | |
# disable some more scheduled tasks | |
Disable-ScheduledTask -TaskName 'ServerManager' -TaskPath '\Microsoft\Windows\Server Manager' | |
Disable-ScheduledTask -TaskName 'ScheduledDefrag' -TaskPath '\Microsoft\Windows\Defrag' | |
Disable-ScheduledTask -TaskName 'ProactiveScan' -TaskPath '\Microsoft\Windows\Chkdsk' | |
Disable-ScheduledTask -TaskName 'Scheduled' -TaskPath '\Microsoft\Windows\Diagnosis' | |
Disable-ScheduledTask -TaskName 'SilentCleanup' -TaskPath '\Microsoft\Windows\DiskCleanup' | |
Disable-ScheduledTask -TaskName 'WinSAT' -TaskPath '\Microsoft\Windows\Maintenance' | |
Disable-ScheduledTask -TaskName 'StartComponentCleanup' -TaskPath '\Microsoft\Windows\Servicing' | |
# disable unnecessary services | |
$services = @( | |
"diagnosticshub.standardcollector.service" # Microsoft (R) Diagnostics Hub Standard Collector Service | |
"DiagTrack" # Diagnostics Tracking Service | |
"dmwappushservice" # WAP Push Message Routing Service | |
"lfsvc" # Geolocation Service | |
"MapsBroker" # Downloaded Maps Manager | |
"NetTcpPortSharing" # Net.Tcp Port Sharing Service | |
"RemoteRegistry" # Remote Registry | |
"SharedAccess" # Internet Connection Sharing (ICS) | |
"TrkWks" # Distributed Link Tracking Client | |
"WbioSrvc" # Windows Biometric Service | |
"Spooler" # Printing stuff | |
"RemoteAccess" # Routing and Remote Access | |
) | |
foreach ($service in $services) { | |
Set-Service $service -startuptype "disabled" | |
Stop-Service $service -force | |
} | |
# show file extensions, hidden items and disable item checkboxes | |
$key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' | |
Set-ItemProperty $key HideFileExt 0 | |
Set-ItemProperty $key HideDrivesWithNoMedia 0 | |
Set-ItemProperty $key Hidden 1 | |
Set-ItemProperty $key AutoCheckSelect 0 | |
# weird accessibility stuff | |
Set-ItemProperty "HKCU:\Control Panel\Accessibility\StickyKeys" "Flags" "506" | |
Set-ItemProperty "HKCU:\Control Panel\Accessibility\Keyboard Response" "Flags" "122" | |
Set-ItemProperty "HKCU:\Control Panel\Accessibility\ToggleKeys" "Flags" "58" | |
# disable telemetry | |
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" "AllowTelemetry" -Value 0 | |
# dont combine taskbar buttons and no tray hiding stuff | |
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name TaskbarGlomLevel -Value 2 | |
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name EnableAutoTray -Value 0 | |
# hide the touchbar button on the systray | |
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PenWorkspace" -Name PenWorkspaceButtonDesiredVisibility -Value 0 | |
######################################## | |
# 7za needed for extracting some exes | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
(New-Object System.Net.WebClient).DownloadFile("http://lg.io/assets/7za.zip", "c:\cloudygamer\downloads\7za.zip") | |
Expand-Archive -LiteralPath "c:\cloudygamer\downloads\7za.zip" -DestinationPath "c:\cloudygamer\7za\" | |
# Use DeviceManagement powershell scripts to detect the video card | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
(New-Object System.Net.WebClient).DownloadFile("https://gallery.technet.microsoft.com/Device-Management-7fad2388/file/65051/2/DeviceManagement.zip", "c:\cloudygamer\downloads\DeviceManagement.zip") | |
Expand-Archive -LiteralPath "c:\cloudygamer\downloads\DeviceManagement.zip" -DestinationPath "c:\cloudygamer\downloads\DeviceManagement" | |
Move-Item "c:\cloudygamer\downloads\DeviceManagement\Release" $PSHOME\Modules\DeviceManagement | |
(Get-Content "$PSHOME\Modules\DeviceManagement\DeviceManagement.psd1").replace("PowerShellHostVersion = '3.0'", "PowerShellHostVersion = ''") | Out-File "$PSHOME\Modules\DeviceManagement\DeviceManagement.psd1" | |
Import-Module DeviceManagement | |
# Download the NVidia device ids, match ours against the list for the name, then figure out NVidia product ids | |
# *** Do not use when GRID driver is necessary (ex. P4, P100) *** | |
$nvidiaDevNamesRaw = (New-Object System.Net.WebClient).DownloadString("https://raw.githubusercontent.com/envytools/envytools/master/docs/hw/pciid.rst") | |
$nvidiaDevNames = $nvidiaDevNamesRaw | select-string -pattern '``0x(.{4}?)``.*? \[(.+?)\]' -allmatches | ForEach-Object {$_.Matches} | ForEach-Object {[PSCustomObject]@{DeviceId=$_.Groups[1].Value.ToUpper(); DeviceName=$_.Groups[2].Value}} | |
$myDeviceIds = get-device | where InstanceId -like "PCI\VEN_10DE&DEV_*" | select InstanceId | select-string -pattern '.*DEV_(.{4}?)&' | foreach-object {$_.Matches.Groups[1].Value} | |
$myCardName = ($myDeviceIds | ForEach-Object { $nvidiaDevNames | where DeviceId -eq $_ } | select-object -first 1)[0].DeviceName | |
[xml]$nvIdsRaw = (New-Object System.Net.WebClient).DownloadString("https://www.nvidia.com/Download/API/lookupValueSearch.aspx?TypeID=3") | |
$nvId = $nvIdsRaw.LookupValueSearch.LookupValues.LookupValue | where Name -like $myCardName | select-object -first 1 | |
$windowsVersion = [regex]::Match((Get-CimInstance Win32_OperatingSystem).Caption, ".*(Windows.*\d+?).*").captures.groups[1].value | |
[xml]$nvIdsRaw = (New-Object System.Net.WebClient).DownloadString("https://www.nvidia.com/Download/API/lookupValueSearch.aspx?TypeID=4") | |
$osId = $nvIdsRaw.LookupValueSearch.LookupValues.LookupValue | where Name -like $windowsVersion | select-object -first 1 | |
# Download the NVidia drivers | |
$resultURL = (New-Object System.Net.WebClient).DownloadString("https://www.nvidia.com/Download/processDriver.aspx?psid=$($nvId.ParentId)&pfid=$($nvId.Value)&rpf=1&osid=$($osId.Value)&lid=1&lang=en-us&ctk=0&dtid=1&dtcid=0") | |
$driverLandingPage = (New-Object System.Net.WebClient).DownloadString($resultURL) | |
$driverURL = "http://us.download.nvidia.com" + $($driverLandingPage -match 'confirmation\.php\?url=(.*?)&' | Out-Null; $Matches[1]) | |
(New-Object System.Net.WebClient).DownloadFile($driverURL, "c:\cloudygamer\downloads\nvidia.exe") | |
& c:\cloudygamer\7za\7za x c:\cloudygamer\downloads\nvidia.exe -oc:\cloudygamer\downloads\nvidia | |
& c:\cloudygamer\downloads\nvidia\setup.exe -clean -noreboot -s | Out-Null | |
Restart-Computer -Force | |
######################################## | |
# disable the basic display adapter and its monitors | |
Import-Module DeviceManagement | |
Get-Device | where Name -eq "Microsoft Basic Display Adapter" | Disable-Device # aws + paperspace | |
Get-Device | where Name -eq "Microsoft Hyper-V Video" | Disable-Device # azure | |
Get-Device | where Name -eq "Generic PnP Monitor" | where DeviceParent -like "*BasicDisplay*" | Disable-Device # azure | |
Get-Device | where Name -eq "Google Graphics Array (GGA)" | Disable-Device # gcp | |
# delete the basic display adapter's drivers (since some games still insist on using the basic adapter) | |
if (Test-Path C:\Windows\System32\Drivers\BasicDisplay.sys) { | |
takeown /f C:\Windows\System32\Drivers\BasicDisplay.sys | |
icacls C:\Windows\System32\Drivers\BasicDisplay.sys /grant "$env:username`:F" | |
move C:\Windows\System32\Drivers\BasicDisplay.sys C:\Windows\System32\Drivers\BasicDisplay.old | |
} | |
# final items: | |
# - remember to turn off location services on macs to prevent latency spikes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment