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