Advertisement
Guest User

Fix NVIDIA HD Audio Driver Settings

a guest
Sep 11th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Author: Chris Kennedy
  2. #Description: Configures NVIDIA HD Audio driver power save settings so that the driver is never put to sleep.
  3. #Version History:
  4.     #1.0 [2019-07-25] - Initial Release
  5.     #1.1 [2019-09-10] - Added better handling for cases where setting the values would fail. Also added instructions to run it in comments
  6. #To run this file, follow these steps:
  7. #1. Save this paste to computer with a .ps1 extension. You can name it whatever you want, but keep the .ps1 extension.
  8. #2. Open a command prompt.
  9. #3. Type "powershell.exe -executionpolicy Bypass" without the quotes and hit enter
  10. #4. Type "cd C:\DIRECTORY\WHERE\YOU\SAVED\THE\FILE" and hit enter. If you saved it to Downloads, you could just type "cd $env:userprofile\Downloads" and hit enter
  11. #5. Type ".\NAMEOFSCRIPT.ps1" and hit enter. If you get a UAC prompt, you will need to hit Yes.
  12. #The script will notify you if it successfully changed the setting, if it failed, or if it couldn't find it at all.
  13.  
  14. Clear-Host
  15.  
  16. #Check to see if this is running as administrator, and if not provide a UAC message and relaunch script.
  17. $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
  18. if (!($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) {
  19.     Write-Host "I have detected that the script is not running as an Administrator."
  20.     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'."
  21.     Pause
  22.     Start-Process -FilePath PowerShell -Verb runas -ArgumentList "-File $($PSCommandPath) -ExecutionPolicy Bypass"
  23.     Exit
  24. }
  25.  
  26. Write-Host "It should take just a moment to find the proper key."
  27. $registryRoot = Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e96c-e325-11ce-bfc1-08002be10318}" -ErrorAction Ignore
  28.  
  29. foreach ($subkey in $registryRoot) {
  30.     $driverKey = Get-ItemProperty -Path $subkey.PSPath
  31.    
  32.     if ($driverKey.DriverDesc -eq "NVIDIA High Definition Audio") {
  33.         Write-Host "NVIDIA Driver located, setting proper values."
  34.         $powerKey = Get-ItemProperty -PSPath "$($subkey.PSPath)\PowerSettings"
  35.  
  36.         try {
  37.             Set-ItemProperty -Path $powerKey.PSPath -Name ConservationIdleTime -Value ([byte[]](0xFF, 0xFF, 0xFF, 0xFF))
  38.             Set-ItemProperty -Path $powerKey.PSPath -Name PerformanceIdleTime -Value ([byte[]](0xFF, 0xFF, 0xFF, 0xFF))
  39.             Set-ItemProperty -Path $powerKey.PSPath -Name IdlePowerState -Value ([byte[]](0x00, 0x00, 0x00, 0x00))
  40.             Write-Host "Successfully configured the registry, a reboot may be required for changes to take effect."
  41.             $driverSet = $true
  42.         }
  43.         catch {
  44.             Write-Host "Failed - $($_.Exception.Message)"
  45.         }
  46.     }
  47.    
  48.     if ($driverSet -ne $true) { Write-Host "I couldn't find the NVIDIA High Definition Audio driver. Are you sure you installed it?" }
  49.     Pause
  50.     Exit
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement