Advertisement
Sweetening

Untitled

Jul 26th, 2024
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. # Disable unnecessary services
  2. $services = @(
  3. "wsearch", # Windows Search
  4. "SysMain", # Superfetch
  5. "wuauserv" # Windows Update
  6. )
  7.  
  8. foreach ($service in $services) {
  9. Set-Service -Name $service -StartupType Disabled
  10. Stop-Service -Name $service -Force
  11. }
  12.  
  13. # Set performance options to 'Adjust for best performance'
  14. $regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects"
  15. $regValue = "VisualFXSetting"
  16.  
  17. if (Test-Path $regPath) {
  18. Set-ItemProperty -Path $regPath -Name $regValue -Value 2
  19. } else {
  20. New-Item -Path $regPath -Force
  21. New-ItemProperty -Path $regPath -Name $regValue -Value 2 -Force
  22. }
  23.  
  24. # Adjust virtual memory (custom size)
  25. $minPageFile = 2048
  26. $maxPageFile = 4096
  27. $computer = Get-WmiObject Win32_ComputerSystem -EnableAllPrivileges
  28. $computer.AutomaticManagedPagefile = $false
  29. $computer.Put()
  30.  
  31. $pageFile = Get-WmiObject Win32_PageFileSetting
  32. if ($pageFile) {
  33. $pageFile.InitialSize = $minPageFile
  34. $pageFile.MaximumSize = $maxPageFile
  35. $pageFile.Put()
  36. } else {
  37. ([WmiClass]"\\.\root\cimv2:Win32_PageFileSetting").Create("C:\pagefile.sys", $minPageFile, $maxPageFile)
  38. }
  39.  
  40. # Disable startup programs
  41. $startupPrograms = @(
  42. "Sidebar",
  43. "AdobeARM",
  44. "QuickTime Task"
  45. )
  46.  
  47. foreach ($program in $startupPrograms) {
  48. $task = Get-ScheduledTask | Where-Object {$_.TaskName -like "*$program*"}
  49. if ($task) {
  50. Disable-ScheduledTask -TaskName $task.TaskName
  51. }
  52. }
  53.  
  54. # Disk cleanup
  55. Start-Process cleanmgr -ArgumentList "/sagerun:1" -NoNewWindow -Wait
  56.  
  57. # Defragment the hard drive
  58. defrag C: -f
  59.  
  60. # Set power plan to high performance
  61. powercfg -setactive SCHEME_MIN
  62.  
  63. # Optimize network settings (disable QoS Packet Scheduler)
  64. $networkAdapters = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.IPEnabled -eq $true}
  65. foreach ($adapter in $networkAdapters) {
  66. $adapter.SettingID
  67. Set-WmiInstance -Path Win32_NetworkAdapterSetting.SettingID=$adapter.SettingID -Arguments @{QoSPacketSchedulerEnabled=$false}
  68. }
  69.  
  70. # Disable visual effects (already done through registry, but ensuring it's enforced)
  71. $visualEffects = @(
  72. "MinAnimate",
  73. "FontSmoothing"
  74. )
  75.  
  76. foreach ($effect in $visualEffects) {
  77. Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name $effect -Value 0
  78. }
  79.  
  80. # Restart to apply changes
  81. Write-Output "Optimizations applied. It's recommended to restart the server to apply all changes."
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement