forked from LeDragoX/Win-Debloat-Tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptimize-services.ps1
127 lines (105 loc) · 6.28 KB
/
optimize-services.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"get-os-info.psm1"
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"title-templates.psm1"
# Adapted from this Baboo video: https://youtu.be/qWESrvP_uU8
# Adapted from this ChrisTitus script: https://github.com/ChrisTitusTech/win10script
# Adapted from this matthewjberger's script: https://gist.github.com/matthewjberger/2f4295887d6cb5738fa34e597f457b7f
# Adapted from this Sycnex script: https://github.com/Sycnex/Windows10Debloater
function Optimize-Services() {
Write-Title -Text "Services tweaks"
$DisableServices = @(
"BITS" # Background Intelligent Transfer Service
"DiagTrack" # Connected User Experiences and Telemetry
"diagnosticshub.standardcollector.service" # Microsoft (R) Diagnostics Hub Standard Collector Service
"dmwappushservice" # Device Management Wireless Application Protocol (WAP)
"GraphicsPerfSvc" # Graphics performance monitor service
"HomeGroupListener" # HomeGroup Listener
"HomeGroupProvider" # HomeGroup Provider
"lfsvc" # Geolocation Service
"MapsBroker" # Downloaded Maps Manager
"ndu" # Windows Network Data Usage Monitoring Driver
"NvContainerLocalSystem" # NVIDIA LocalSystem Container (GeForce Experience / NVIDIA Telemetry)
"PcaSvc" # Program Compatibility Assistant (PCA)
"RemoteAccess" # Routing and Remote Access
"RemoteRegistry" # Remote Registry
"SysMain" # SysMain / Superfetch (100% Disk on HDDs)
"TrkWks" # Distributed Link Tracking Client
"WbioSrvc" # Windows Biometric Service (required for Fingerprint reader / facial detection)
"WSearch" # Windows Search (100% Disk on HDDs)
# <==========[DIY]==========> (Remove the # to Disable)
#"DPS" # Diagnostic Policy Service
#"NetTcpPortSharing" # Net.Tcp Port Sharing Service
#"SharedAccess" # Internet Connection Sharing (ICS)
#"stisvc" # Windows Image Acquisition (WIA)
#"WlanSvc" # WLAN AutoConfig
#"Wecsvc" # Windows Event Collector
#"WerSvc" # Windows Error Reporting Service
#"wscsvc" # Windows Security Center Service
#"WdiServiceHost" # Diagnostic Service Host
#"WdiSystemHost" # Diagnostic System Host
#"WMPNetworkSvc" # Windows Media Player Network Sharing Service (Miracast / Wi-Fi Direct)
# [DIY] If you don't use Bluetooth devices
#"BTAGService" # Bluetooth Audio Gateway Service
#"bthserv" # Bluetooth Support Service
# [DIY] If you don't use a Printer
#"Spooler" # Print Spooler
#"PrintNotify" # Printer Extensions and Notifications
# [DIY] If you don't use Xbox Live and Games
#"XblAuthManager" # Xbox Live Auth Manager
#"XblGameSave" # Xbox Live Game Save Service
#"XboxGipSvc" # Xbox Accessory Management Service
#"XboxNetApiSvc" # Xbox Live Networking Service
# Services which cannot be disabled
#"WdNisSvc"
)
ForEach ($Service in $DisableServices) {
If (Get-Service $Service -ErrorAction SilentlyContinue) {
If (($Revert -eq $true) -and ($Service -match "RemoteRegistry")) {
Write-Warning "[?][Services] Skipping $Service to avoid a security vulnerability..."
Continue
}
Write-Host "$($EnableStatus[0]) $Service at Startup..."
Invoke-Expression "$($Commands[0])"
}
Else {
Write-Warning "[?][Services] $Service was not found."
}
}
If ($IsSystemDriveSSD? -and $null -eq $Revert) {
$EnableServicesSSD = @(
"SysMain" # SysMain / Superfetch (100% Disk on HDDs)
"WSearch" # Windows Search (100% Disk on HDDs)
)
ForEach ($Service in $EnableServicesSSD) {
Write-Host "$($EnableStatus[2]) $Service at Startup because SSDs will have more benefits..."
Invoke-Expression "$($Commands[2])"
}
}
}
function Main() {
$EnableStatus = @(
"[-][Services] Disabling",
"[+][Services] Enabling"
"[+][Services] Enabling (Automatic)"
)
$Commands = @(
{ Get-Service -Name "$Service" -ErrorAction SilentlyContinue | Set-Service -StartupType Disabled },
{ Get-Service -Name "$Service" -ErrorAction SilentlyContinue | Set-Service -StartupType Manual }
{ Get-Service -Name "$Service" -ErrorAction SilentlyContinue | Set-Service -StartupType Automatic }
)
if (($Revert)) {
Write-Warning "[<][Services] Reverting: $Revert."
$EnableStatus = @(
"[<][Services] Re-Enabling",
"[<][Services] Re-Disabling"
"[+][Services] Enabling (Automatic)"
)
$Commands = @(
{ Get-Service -Name "$Service" -ErrorAction SilentlyContinue | Set-Service -StartupType Manual },
{ Get-Service -Name "$Service" -ErrorAction SilentlyContinue | Set-Service -StartupType Disabled }
{ Get-Service -Name "$Service" -ErrorAction SilentlyContinue | Set-Service -StartupType Automatic }
)
}
$IsSystemDriveSSD? = Get-OSDriveType
Optimize-Services # Enable essential Services and Disable bloating Services
}
Main