Advertisement
Harze2k

Windows Basic Tweaks by Melody Rev. 2.0

Nov 11th, 2023
2,519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PowerShell 14.18 KB | Source Code | 0 0
  1. #########################################################################################################
  2. #Read all about the tweaks here on Melodys page: https://sites.google.com/view/melodystweaks/basictweaks#
  3. #########################################################################################################
  4. # in 2.0 you can actually overwrite current values! Amazing i know..smh :D
  5. function Set-RegistryValue {
  6.     param (
  7.         [string]$path,
  8.         [string]$name,
  9.         $value,
  10.         [string]$type = "DWord",
  11.         [switch]$Force
  12.     )
  13.     # Check if the key exists and create it if it doesn't
  14.     $key = Get-Item -Path $path -ErrorAction SilentlyContinue
  15.     if ($null -eq $key) {
  16.         try {
  17.             New-Item -Path $path -Force | Out-Null
  18.             $key = Get-Item -Path $path
  19.             Write-Host "Creating key at $path." -ForegroundColor Green
  20.         }
  21.         catch {
  22.             Write-Warning "Failed to create key $key. $_"
  23.         }
  24.     }
  25.     else {
  26.         Write-Host "Key at $path already exists."
  27.     }
  28.     # Set the value, overwriting if it exists when -Force is specified
  29.     try {
  30.         if ($Force -or ($key.GetValue($name, "NotExist") -eq "NotExist")) {
  31.             Set-ItemProperty -Path $path -Name $name -Value $value -Type $type -Force | Out-Null
  32.             Write-Host "Setting $type value $name to $value." -ForegroundColor Green
  33.         }
  34.         else {
  35.             Write-Host "$type value $name with existing value already exists. Use -Force to overwrite." -ForegroundColor Yellow
  36.         }
  37.     }
  38.     catch {
  39.         Write-Warning "Failed to set value $name at $path. $_"
  40.     }
  41. }
  42. # Registry settings
  43. $registryValues = @{
  44.     "HKLM:\SOFTWARE\Policies\Microsoft\FVE"                                                                 = @{
  45.         "DisableExternalDMAUnderLock" = @{ Value = 0; Type = "DWord" }
  46.     }
  47.     "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeviceGuard"                                                 = @{
  48.         "EnableVirtualizationBasedSecurity" = @{ Value = 0; Type = "DWord" }
  49.         "HVCIMATRequired"                   = @{ Value = 0; Type = "DWord" }
  50.     }
  51.     "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\kernel"                                         = @{
  52.         "DisableExceptionChainValidation" = @{ Value = 1; Type = "DWord" }
  53.         "KernelSEHOPEnabled"              = @{ Value = 0; Type = "DWord" }
  54.     }
  55.     "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\csrss.exe\PerfOptions" = @{
  56.         "CpuPriorityClass" = @{ Value = 4; Type = "DWord" }
  57.         "IoPriority"       = @{ Value = 3; Type = "DWord" }
  58.     }
  59.     "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management"                              = @{
  60.         "FeatureSettings"             = @{ Value = 1; Type = "DWord" }
  61.         "FeatureSettingsOverride"     = @{ Value = 3; Type = "DWord" }
  62.         "FeatureSettingsOverrideMask" = @{ Value = 3; Type = "DWord" }
  63.         "EnableCfg"                   = @{ Value = 0; Type = "DWord" }
  64.         "DisablePagingExecutive"      = @{ Value = 1; Type = "DWord" }
  65.         "LargeSystemCache"            = @{ Value = 1; Type = "DWord" }
  66.     }
  67.     "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager"                                                = @{
  68.         "ProtectionMode" = @{ Value = 0; Type = "DWord" }
  69.     }
  70.     "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Reliability"                                           = @{
  71.         "TimeStampInterval" = @{ Value = 1; Type = "DWord" }
  72.     }
  73.     "HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers"                                                = @{
  74.         "DpiMapIommuContiguous" = @{ Value = 1; Type = "DWord" }
  75.     }
  76.     #####################################################################
  77.     #NVIDIA VALUES - CHANGE TO AMD VALUES DOWN BELOW YOU HAVE A AMD CARD#
  78.     #####################################################################
  79.     "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0000"              = @{
  80.         "PreferSystemMemoryContiguous"       = @{ Value = 1; Type = "DWord" }
  81.         "D3PCLatency"                        = @{ Value = 1; Type = "DWord" }
  82.         "F1TransitionLatency"                = @{ Value = 1; Type = "DWord" }
  83.         "LOWLATENCY"                         = @{ Value = 1; Type = "DWord" }
  84.         "Node3DLowLatency"                   = @{ Value = 1; Type = "DWord" }
  85.         "PciLatencyTimerControl"             = @{ Value = 32; Type = "DWord" }
  86.         "RMDeepL1EntryLatencyUsec"           = @{ Value = 1; Type = "DWord" }
  87.         "RmGspcMaxFtuS"                      = @{ Value = 1; Type = "DWord" }
  88.         "RmGspcMinFtuS"                      = @{ Value = 1; Type = "DWord" }
  89.         "RmGspcPerioduS"                     = @{ Value = 1; Type = "DWord" }
  90.         "RMLpwrEiIdleThresholdUs"            = @{ Value = 1; Type = "DWord" }
  91.         "RMLpwrGrIdleThresholdUs"            = @{ Value = 1; Type = "DWord" }
  92.         "RMLpwrGrRgIdleThresholdUs"          = @{ Value = 1; Type = "DWord" }
  93.         "RMLpwrMsIdleThresholdUs"            = @{ Value = 1; Type = "DWord" }
  94.         "VRDirectFlipDPCDelayUs"             = @{ Value = 1; Type = "DWord" }
  95.         "VRDirectFlipTimingMarginUs"         = @{ Value = 1; Type = "DWord" }
  96.         "VRDirectJITFlipMsHybridFlipDelayUs" = @{ Value = 1; Type = "DWord" }
  97.         "vrrCursorMarginUs"                  = @{ Value = 1; Type = "DWord" }
  98.         "vrrDeflickerMarginUs"               = @{ Value = 1; Type = "DWord" }
  99.         "vrrDeflickerMaxUs"                  = @{ Value = 1; Type = "DWord" }
  100.         #"LTRSnoopL0Latency"                  = @{ Value = 1; Type = "DWord" }
  101.         #"LTRNoSnoopL1Latency"                = @{ Value = 1; Type = "DWord" }
  102.         #"LTRMaxNoSnoopLatency"               = @{ Value = 1; Type = "DWord" }
  103.         #"KMD_RpmComputeLatency"              = @{ Value = 1; Type = "DWord" }
  104.         #"DalUrgentLatencyNs"                 = @{ Value = 1; Type = "DWord" }
  105.         #"memClockSwitchLatency"              = @{ Value = 1; Type = "DWord" }
  106.         #"PP_RTPMComputeF1Latency"            = @{ Value = 1; Type = "DWord" }
  107.         #"PP_DGBMMMaxTransitionLatencyUvd"    = @{ Value = 1; Type = "DWord" }
  108.         #"PP_DGBPMMaxTransitionLatencyGfx"    = @{ Value = 1; Type = "DWord" }
  109.         #"DalNBLatencyForUnderFlow"           = @{ Value = 1; Type = "DWord" }
  110.         #"DalDramClockChangeLatencyNs"        = @{ Value = 1; Type = "DWord" } #(WARNING: This dword caused massive screen flickering for some people, use it at your own risk. If you're already using it and you have problems, simply delete the dword and reboot the system)
  111.         #"BGM_LTRSnoopL1Latency"              = @{ Value = 1; Type = "DWord" }
  112.         #"BGM_LTRSnoopL0Latency"              = @{ Value = 1; Type = "DWord" }
  113.         #"BGM_LTRNoSnoopL1Latency"            = @{ Value = 1; Type = "DWord" }
  114.         #"BGM_LTRNoSnoopL0Latency"            = @{ Value = 1; Type = "DWord" }
  115.         #"BGM_LTRMaxSnoopLatencyValue"        = @{ Value = 1; Type = "DWord" }
  116.         #"BGM_LTRMaxNoSnoopLatencyValue"      = @{ Value = 1; Type = "DWord" }
  117.     }
  118.     "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"                                              = @{
  119.         "AllowTelemetry" = @{ Value = 0; Type = "DWord" }
  120.     }
  121.     "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat"                                                   = @{
  122.         "AITEnable" = @{ Value = 0; Type = "DWord" }
  123.     }
  124.     "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting"                                     = @{
  125.         "Disabled" = @{ Value = 1; Type = "DWord" }
  126.     }
  127.     "HKLM:\SOFTWARE\Policies\Microsoft\Windows\QoS"                                                         = @{
  128.         "Tcp Autotuning Level"             = @{ Value = "Experimental"; Type = "String" }
  129.         "Application DSCP Marking Request" = @{ Value = "Allowed"; Type = "String" }
  130.     }
  131.     "HKLM:\SYSTEM\CurrentControlSet\Services\mouclass\Parameters"                                           = @{
  132.         "MouseDataQueueSize" = @{ Value = 16; Type = "DWord" }
  133.     }
  134.     "HKLM:\SYSTEM\CurrentControlSet\Services\kbdclass\Parameters"                                           = @{
  135.         "KeyboardDataQueueSize" = @{ Value = 16; Type = "DWord" }
  136.     }
  137.     "HKLM:\SYSTEM\CurrentControlSet\Control\Power"                                                          = @{
  138.         "ExitLatency"                  = @{ Value = 1; Type = "DWord" }
  139.         "ExitLatencyCheckEnabled"      = @{ Value = 1; Type = "DWord" }
  140.         "Latency"                      = @{ Value = 1; Type = "DWord" }
  141.         "LatencyToleranceDefault"      = @{ Value = 1; Type = "DWord" }
  142.         "LatencyToleranceFSVP"         = @{ Value = 1; Type = "DWord" }
  143.         "LatencyTolerancePerfOverride" = @{ Value = 1; Type = "DWord" }
  144.         "LatencyToleranceScreenOffIR"  = @{ Value = 1; Type = "DWord" }
  145.         "LatencyToleranceVSyncEnabled" = @{ Value = 1; Type = "DWord" }
  146.         "RtlCapabilityCheckLatency"    = @{ Value = 1; Type = "DWord" }
  147.     }
  148.     "HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Power"                                          = @{
  149.         "DefaultD3TransitionLatencyActivelyUsed"           = @{ Value = 1; Type = "DWord" }
  150.         "DefaultD3TransitionLatencyIdleLongTime"           = @{ Value = 1; Type = "DWord" }
  151.         "DefaultD3TransitionLatencyIdleMonitorOff"         = @{ Value = 1; Type = "DWord" }
  152.         "DefaultD3TransitionLatencyIdleNoContext"          = @{ Value = 1; Type = "DWord" }
  153.         "DefaultD3TransitionLatencyIdleShortTime"          = @{ Value = 1; Type = "DWord" }
  154.         "DefaultD3TransitionLatencyIdleVeryLongTime"       = @{ Value = 1; Type = "DWord" }
  155.         "DefaultLatencyToleranceIdle0"                     = @{ Value = 1; Type = "DWord" }
  156.         "DefaultLatencyToleranceIdle0MonitorOff"           = @{ Value = 1; Type = "DWord" }
  157.         "DefaultLatencyToleranceIdle1"                     = @{ Value = 1; Type = "DWord" }
  158.         "DefaultLatencyToleranceIdle1MonitorOff"           = @{ Value = 1; Type = "DWord" }
  159.         "DefaultLatencyToleranceMemory"                    = @{ Value = 1; Type = "DWord" }
  160.         "DefaultLatencyToleranceNoContext"                 = @{ Value = 1; Type = "DWord" }
  161.         "DefaultLatencyToleranceNoContextMonitorOff"       = @{ Value = 1; Type = "DWord" }
  162.         "DefaultLatencyToleranceOther"                     = @{ Value = 1; Type = "DWord" }
  163.         "DefaultLatencyToleranceTimerPeriod"               = @{ Value = 1; Type = "DWord" }
  164.         "DefaultMemoryRefreshLatencyToleranceActivelyUsed" = @{ Value = 1; Type = "DWord" }
  165.         "DefaultMemoryRefreshLatencyToleranceMonitorOff"   = @{ Value = 1; Type = "DWord" }
  166.         "DefaultMemoryRefreshLatencyToleranceNoContext"    = @{ Value = 1; Type = "DWord" }
  167.         "Latency"                                          = @{ Value = 1; Type = "DWord" }
  168.         "MaxIAverageGraphicsLatencyInOneBucket"            = @{ Value = 1; Type = "DWord" }
  169.         "MiracastPerfTrackGraphicsLatency"                 = @{ Value = 1; Type = "DWord" }
  170.         "MonitorLatencyTolerance"                          = @{ Value = 1; Type = "DWord" }
  171.         "MonitorRefreshLatencyTolerance"                   = @{ Value = 1; Type = "DWord" }
  172.         "TransitionLatency"                                = @{ Value = 1; Type = "DWord" }
  173.     }
  174.     "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"                                       = @{
  175.         "VerboseStatus" = @{ Value = 1; Type = "DWord" }
  176.     }
  177. }
  178. # Apply registry settings
  179. foreach ($path in $registryValues.Keys) {
  180.     foreach ($name in $registryValues[$path].Keys) {
  181.         $value = $registryValues[$path][$name].Value
  182.         $type = $registryValues[$path][$name].Type
  183.         Set-RegistryValue -path $path -name $name -value $value -type $type -Force #Added -Force to overwrite current values.
  184.     }
  185. }
  186. # BCDEdit commands
  187. bcdedit /set linearaddress57 OptOut
  188. bcdedit /set increaseuserva 268435328
  189. bcdedit /set firstmegabytepolicy UseAll
  190. bcdedit /set avoidlowmemory 0x8000000
  191. bcdedit /set nolowmem Yes
  192. bcdedit /set allowedinmemorysettings 0x0
  193. bcdedit /set isolatedcontext No
  194. bcdedit /set vsmlaunchtype Off
  195. bcdedit /set vm No
  196. bcdedit /set x2apicpolicy Enable
  197. bcdedit /set configaccesspolicy Default
  198. bcdedit /set MSI Default
  199. bcdedit /set usephysicaldestination No
  200. bcdedit /set usefirmwarepcisettings No
  201. bcdedit /deletevalue useplatformclock
  202. bcdedit /deletevalue disabledynamictick
  203. bcdedit /set useplatformtick Yes
  204. bcdedit /set tscsyncpolicy Enhanced
  205. bcdedit /set disableelamdrivers Yes
  206.  
  207. # Netsh commands
  208. netsh int tcp set global autotuning=experimental
  209. netsh int tcp set supp internet congestionprovider=newreno
  210. netsh int udp set global uro=enabled
  211. netsh int teredo set state natawareclient
  212. netsh int 6to4 set state state=enabled
  213. netsh advfirewall set allprofiles state on
  214. netsh winsock set autotuning on
  215.  
  216. # PowerShell commands
  217. Disable-MMAgent -MemoryCompression -ErrorAction SilentlyContinue
  218. Get-NetAdapter -IncludeHidden | Set-NetIPInterface -WeakHostSend Enabled -WeakHostReceive Enabled -ErrorAction SilentlyContinue
  219. ForEach ($v in (Get-Command -Name "Set-ProcessMitigation").Parameters["Disable"].Attributes.ValidValues) {
  220.     if ($v.ToString()) {
  221.         try {
  222.             Set-ProcessMitigation -System -Disable $v.ToString() -ErrorAction Stop
  223.             Write-Host "Setting process mitigation on: $($v.toString())" -ForegroundColor Green
  224.         }
  225.         catch {
  226.             Write-Warning "Could not set process mitigation on: $($v.toString())"
  227.         }
  228.     }
  229. }
  230. Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\*" -Recurse -ErrorAction SilentlyContinue
  231.  
  232. # WMIC commands
  233. $computerSystem = Get-CimInstance -ClassName Win32_ComputerSystem -ErrorAction SilentlyContinue
  234. $computerSystem.AutomaticManagedPagefile = $false
  235. Set-CimInstance -InputObject $computerSystem -ErrorAction SilentlyContinue
  236.  
  237. $pageFile = Get-CimInstance -ClassName Win32_PageFileSetting -Filter "Name='C:\\pagefile.sys'" -ErrorAction SilentlyContinue
  238. $pageFile.InitialSize = 32768
  239. $pageFile.MaximumSize = 32768
  240. Set-CimInstance -InputObject $pageFile -ErrorAction SilentlyContinue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement