diff --git a/Fix-GPUTimeoutDetectionResponse.ps1 b/Fix-GPUTimeoutDetectionResponse.ps1 index 2a98a26..59921f1 100644 --- a/Fix-GPUTimeoutDetectionResponse.ps1 +++ b/Fix-GPUTimeoutDetectionResponse.ps1 @@ -1,5 +1,30 @@ -#[Microsoft.Win32.Registry]::SetValue('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers','TdrLevel',3,[Microsoft.Win32.RegistryValueKind]::DWord) +# Exit script if required variables are not defined +If ( !$TdrLevel ) { Write-Error "TdrLevel must be defined, this script will now exit." ; Exit } +If ( !$TdrDelay ) { Write-Error "TdrDelay must be defined, this script will now exit." ; Exit } -# Setting TDR timeout to 64 seconds instead of the default 2 seconds -Write-Output "Setting TDR timeout value to 64 seconds" -[Microsoft.Win32.Registry]::SetValue('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers','TdrDelay',64,[Microsoft.Win32.RegistryValueKind]::DWord) \ No newline at end of file +# Set the root registry path +$RegPath = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers' + +# Get/set the TDR level +$ExistingTdrLevel = [Microsoft.Win32.Registry]::GetValue($RegPath,'TdrLevel',3) +If ( $TdrLevel -ne $ExistingTdrLevel ) { + # Set the TDR level + # Note: 1 = Disable, 3 = Recover (default) + Write-Output "Existing TDR level: ${ExistingTdrLevel}" + Write-Output "Changing TDR level to: ${TdrLevel}" + [Microsoft.Win32.Registry]::SetValue($RegPath,'TdrLevel',$TdrLevel,[Microsoft.Win32.RegistryValueKind]::DWord) +} Else { + Write-Output "TDR value is already set to ${TdrLevel}" +} + +# Get/set the TDR delay +$ExistingTdrValue = [Microsoft.Win32.Registry]::GetValue($RegPath,'TdrDelay',2) +If ( $TdrDelay -ne $ExistingTdrValue ) { + # Setting TDR timeout to $TdrDelay seconds + # Note: 2 = Default + Write-Output "Existing TDR value: ${ExistingTdrValue}" + Write-Output "Changing TDR value to: ${TdrDelay}" + [Microsoft.Win32.Registry]::SetValue($RegPath,'TdrDelay',$TdrDelay,[Microsoft.Win32.RegistryValueKind]::DWord) +} Else { + Write-Output "TDR delay is already set to ${TdrDelay}" +}