Advertisement
Computermaster

Untitled

Jul 25th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Author: Chris Kennedy
  2. #Description: Configures Vive driver power save settings so that the driver is never put to sleep.
  3. #Version History:
  4.     #1.0 [2018-07-25] - Initial Release
  5.  
  6. Clear-Host
  7.  
  8. #Check to see if this is running as administrator, and if not provide a UAC message and relaunch script.
  9. $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
  10. if (!($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) {
  11.     Write-Host "I have detected that the script is not running as an Administrator."
  12.     Write-Host "I will relaunch the script. If you see a prompt from 'User Account Control' asking if you want to allow PowerShell to make changes, you must click 'Yes'."
  13.     Pause
  14.     Start-Process -FilePath PowerShell -Verb runas -ArgumentList "-File $($PSCommandPath) -ExecutionPolicy Bypass"
  15.     Exit
  16. }
  17.  
  18. Write-Host "It should take just a moment to find the proper key."
  19.  
  20. #Gathers all the subkeys
  21. $registryRoot = Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e96c-e325-11ce-bfc1-08002be10318}" -ErrorAction Ignore
  22.  
  23. #Iterates through each subkey so we can determine if we need to touch it.
  24. foreach ($subkey in $registryRoot) {
  25.     $driverKey = Get-ItemProperty -Path $subkey.PSPath
  26.    
  27.     #The only one we want to change is the one for NVIDIA HD Audio
  28.     if ($driverKey.DriverDesc -eq "NVIDIA High Definition Audio") {
  29.         Write-Host "NVIDIA Driver located, setting proper values."
  30.         $powerKey = Get-ItemProperty -PSPath "$($subkey.PSPath)\PowerSettings"
  31.  
  32.         try {
  33.             Set-ItemProperty -Path $powerKey.PSPath -Name ConservationIdleTime -Value ([byte[]](0xFF, 0xFF, 0xFF, 0xFF))
  34.             Set-ItemProperty -Path $powerKey.PSPath -Name PerformanceIdleTime -Value ([byte[]](0xFF, 0xFF, 0xFF, 0xFF))
  35.             Set-ItemProperty -Path $powerKey.PSPath -Name IdlePowerState -Value ([byte[]](0x00, 0x00, 0x00, 0x00))
  36.             Write-Host "Successfully configured the registry, a reboot may be required for changes to take effect."
  37.             Pause
  38.             Exit
  39.         }
  40.         catch {
  41.             Write-Host "Failed - $($_.Exception.Message)"
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement