Advertisement
Computermaster

Fix NVIDIA HD Audio Driver Settings

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