use variable vals, check existing vals first
This commit is contained in:
@@ -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
|
# Set the root registry path
|
||||||
Write-Output "Setting TDR timeout value to 64 seconds"
|
$RegPath = 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers'
|
||||||
[Microsoft.Win32.Registry]::SetValue('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GraphicsDrivers','TdrDelay',64,[Microsoft.Win32.RegistryValueKind]::DWord)
|
|
||||||
|
# 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}"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user