Skip to content

Commit

Permalink
Rename optimize-optional-features file
Browse files Browse the repository at this point in the history
- Commented all commands to List all Services, Scheduled Tasks, Appx Packages and different Windows Features
- Updated file on README
- Change console outputing from optimize-privacy-and-performance
- Moved some tweaks between privacy and performance
- Moved task manager tweak to personal tweaks
  • Loading branch information
LeDragoX committed Apr 9, 2022
1 parent 3928784 commit 0803cb1
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 62 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force; ls -Recurse *.ps*1 |
- Apply General Personalization tweaks via Registry and Powershell commands; ([`personal-tweaks.ps1`](./src/scripts/personal-tweaks.ps1))
- Help improve the Security of Windows while maintaining performance; ([`optimize-security.ps1`](./src/scripts/optimize-security.ps1))
- Remove OneDrive completely from the System, re-install is possible via Win Store; ([`remove-onedrive.ps1`](./src/scripts/remove-onedrive.ps1))
- Disable/Enable Optional Features specially for Gaming/Work; ([`optimize-optional-features.ps1`](./src/scripts/optimize-optional-features.ps1))
- Disable/Enable Windows Features specially for Gaming/Productivity; ([`optimize-windows-features.ps1`](./src/scripts/optimize-windows-features.ps1))
- Install WSL Preview (Only works for Windows 11): ([`win11-wsl-preview-install.ps1`](./src/scripts/win11-wsl-preview-install.ps1))
- In the End it Locks Script's Usage Permission. ([`set-script-policy.psm1`](./src/lib/set-script-policy.psm1))

Expand Down
2 changes: 1 addition & 1 deletion Win10ScriptCLI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function Open-Script() {
"personal-tweaks.ps1",
"optimize-security.ps1",
"remove-onedrive.ps1",
"optimize-optional-features.ps1",
"optimize-windows-features.ps1",
"win11-wsl-preview-install.ps1"
)

Expand Down
4 changes: 2 additions & 2 deletions Win10ScriptGUI.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ function Show-GUI() {
"personal-tweaks.ps1",
"optimize-security.ps1",
"remove-onedrive.ps1",
"optimize-optional-features.ps1",
"optimize-windows-features.ps1",
"win11-wsl-preview-install.ps1"
)

Expand Down Expand Up @@ -563,7 +563,7 @@ function Show-GUI() {
"optimize-services.ps1",
"optimize-privacy-and-performance.ps1",
"personal-tweaks.ps1",
"optimize-optional-features.ps1",
"optimize-windows-features.ps1",
"reinstall-pre-installed-apps.ps1"
)
Open-PowerShellFilesCollection -RelativeLocation "src\scripts" -Scripts $Scripts -DoneTitle $DoneTitle -DoneMessage $DoneMessage
Expand Down
98 changes: 46 additions & 52 deletions src/scripts/optimize-privacy-and-performance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ function Optimize-PrivacyAndPerformance() {
[Int] $Zero = 0,
[Int] $One = 1,
[Array] $EnableStatus = @(
"[-][Priv&Perf] Disabling",
"[+][Priv&Perf] Enabling"
"[-][Privacy] Disabling",
"[+][Privacy] Enabling",
"[-][Performance] Disabling",
"[+][Performance] Enabling"
)
)

If (($Revert)) {
Write-Warning "[<][Priv&Perf] Reverting: $Revert."
Write-Warning "[<][Privacy/Performance] Reverting: $Revert."
$Zero = 1
$One = 0
$EnableStatus = @(
"[<][Priv&Perf] Re-Enabling",
"[<][Priv&Perf] Re-Disabling"
"[<][Privacy] Re-Enabling",
"[<][Privacy] Re-Disabling",
"[<][Performance] Re-Enabling",
"[<][Performance] Re-Disabling"
)
}

Expand Down Expand Up @@ -84,13 +88,13 @@ function Optimize-PrivacyAndPerformance() {
"SystemPaneSuggestionsEnabled"
)

Write-Warning "[?][Priv&Perf] From Path: [$PathToCUContentDeliveryManager]."
Write-Warning "[?][Privacy] From Path: [$PathToCUContentDeliveryManager]."
ForEach ($Name in $ContentDeliveryManagerDisableOnZero) {
Write-Host "$($EnableStatus[0]) $($Name): $Zero"
Set-ItemProperty -Path "$PathToCUContentDeliveryManager" -Name "$Name" -Type DWord -Value $Zero
}

Write-Host "[-][Priv&Perf] Disabling 'Suggested Content in the Settings App'..."
Write-Host "[-][Privacy] Disabling 'Suggested Content in the Settings App'..."
If (Test-Path "$PathToCUContentDeliveryManager\Subscriptions") {
Remove-Item -Path "$PathToCUContentDeliveryManager\Subscriptions" -Recurse
}
Expand Down Expand Up @@ -162,8 +166,8 @@ function Optimize-PrivacyAndPerformance() {
"UploadUserActivities"
)

Write-Warning "[?][Privacy] From Path: [$PathToLMActivityHistory]"
ForEach ($Name in $ActivityHistoryDisableOnZero) {
Write-Warning "[?][Priv&Perf] From Path: [$PathToLMActivityHistory]"
Write-Host "$($EnableStatus[0]) $($Name): $Zero"
Set-ItemProperty -Path "$PathToLMActivityHistory" -Name "$ActivityHistoryDisableOnZero" -Type DWord -Value $Zero
}
Expand All @@ -187,7 +191,7 @@ function Optimize-PrivacyAndPerformance() {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\userAccountInformation" -Name "Value" -Value "Deny"

Write-Caption -Text "Other Devices"
Write-Host "[-][Priv&Perf] Denying device access..."
Write-Host "[-][Privacy] Denying device access..."
If (!(Test-Path "$PathToCUDeviceAccessGlobal\LooselyCoupled")) {
New-Item -Path "$PathToCUDeviceAccessGlobal\LooselyCoupled" -Force | Out-Null
}
Expand All @@ -208,7 +212,7 @@ function Optimize-PrivacyAndPerformance() {

Write-Section -Text "Update & Security"
Write-Caption -Text "Windows Update"
Write-Host "[-][Priv&Perf] Disabling Automatic Download and Installation of Windows Updates..."
Write-Host "[-][Privacy] Disabling Automatic Download and Installation of Windows Updates..."
If (!(Test-Path "$PathToLMPoliciesWindowsUpdate")) {
New-Item -Path "$PathToLMPoliciesWindowsUpdate" -Force | Out-Null
}
Expand All @@ -220,11 +224,11 @@ function Optimize-PrivacyAndPerformance() {
# [@] (0 = Enable Automatic Updates, 1 = Disable Automatic Updates)
Set-ItemProperty -Path "$PathToLMPoliciesWindowsUpdate" -Name "NoAutoUpdate" -Type DWord -Value $Zero

Write-Host "[+][Priv&Perf] Setting Scheduled Day to Every day..."
Write-Host "[+][Privacy] Setting Scheduled Day to Every day..."
# [@] (0 = Every day, 1~7 = The days of the week from Sunday (1) to Saturday (7) (Only valid if AUOptions = 4))
Set-ItemProperty -Path "$PathToLMPoliciesWindowsUpdate" -Name "ScheduledInstallDay" -Type DWord -Value 0

Write-Host "[-][Priv&Perf] Setting Scheduled time to 03h00m..."
Write-Host "[-][Privacy] Setting Scheduled time to 03h00m..."
# [@] (0-23 = The time of day in 24-hour format)
Set-ItemProperty -Path "$PathToLMPoliciesWindowsUpdate" -Name "ScheduledInstallTime" -Type DWord -Value 3

Expand All @@ -240,7 +244,7 @@ function Optimize-PrivacyAndPerformance() {
Set-ItemProperty -Path "$PathToLMDeliveryOptimizationCfg" -Name "DODownloadMode" -Type DWord -Value $One

Write-Caption -Text "Troubleshooting"
Write-Host "[+][Priv&Perf] Enabling Automatic Recommended Troubleshooting, then notify me..."
Write-Host "[+][Privacy] Enabling Automatic Recommended Troubleshooting, then notify me..."
If (!(Test-Path "$PathToLMWindowsTroubleshoot")) {
New-Item -Path "$PathToLMWindowsTroubleshoot" -Force | Out-Null
}
Expand All @@ -259,8 +263,8 @@ function Optimize-PrivacyAndPerformance() {
"DisableThirdPartySuggestions"
)

Write-Warning "[?][Priv&Perf] From Path: [$PathToCUPoliciesCloudContent]."
ForEach ($Name in $CloudContentDisableOnOne) {
Write-Warning "[?][Privacy] From Path: [$PathToCUPoliciesCloudContent]."
Write-Host "$($EnableStatus[0]) $($Name): $One"
Set-ItemProperty -Path "$PathToCUPoliciesCloudContent" -Name "$Name" -Type DWord -Value $One
}
Expand Down Expand Up @@ -311,34 +315,6 @@ function Optimize-PrivacyAndPerformance() {
}
Set-ItemProperty -Path "$PathToLMPoliciesToWifi\AllowAutoConnectToWiFiSenseHotspots" -Name "value" -Type DWord -Value $Zero

Write-Section -Text "Gaming"
Write-Host "$($EnableStatus[0]) Game Bar & Game DVR..."
$Scripts = @("disable-game-bar-dvr.reg")
If ($Revert) {
$Scripts = @("enable-game-bar-dvr.reg")
}
Open-RegFilesCollection -RelativeLocation "src\utils" -Scripts $Scripts -DoneTitle "" -DoneMessage "" -NoDialog

Write-Host "[=][Priv&Perf] Enabling game mode..."
Set-ItemProperty -Path "$PathToCUGameBar" -Name "AllowAutoGameMode" -Type DWord -Value 1
Set-ItemProperty -Path "$PathToCUGameBar" -Name "AutoGameModeEnabled" -Type DWord -Value 1

Write-Section -Text "System"
Write-Caption -Text "Display"
Write-Host "[+][Priv&Perf] Enable Hardware Accelerated GPU Scheduling... (Windows 10 20H1+ - Needs Restart)"
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers" -Name "HwSchMode" -Type DWord -Value 2

# Show Task Manager details - Applicable to 1607 and later - Although this functionality exist even in earlier versions, the Task Manager's behavior is different there and is not compatible with this tweak
Write-Host "$($EnableStatus[1]) Showing task manager details..."
$taskmgr = Start-Process -WindowStyle Hidden -FilePath taskmgr.exe -PassThru
Do {
Start-Sleep -Milliseconds 100
$preferences = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -ErrorAction SilentlyContinue
} Until ($preferences)
Stop-Process $taskmgr
$preferences.Preferences[28] = 0
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -Type Binary -Value $preferences.Preferences

Write-Caption "Deleting useless registry keys..."
$KeysToDelete = @(
# Remove Background Tasks
Expand Down Expand Up @@ -369,37 +345,55 @@ function Optimize-PrivacyAndPerformance() {

ForEach ($Key in $KeysToDelete) {
If ((Test-Path $Key)) {
Write-Host "[Priv&Perf] Removing Key: [$Key]"
Write-Host "[Privacy] Removing Key: [$Key]"
Remove-Item $Key -Recurse
}
}

Write-Title -Text "Performance Tweaks"
Write-Host "$($EnableStatus[0]) SysMain/Superfetch..."

Write-Section -Text "Gaming"
Write-Host "$($EnableStatus[0]) Game Bar & Game DVR..."
$Scripts = @("disable-game-bar-dvr.reg")
If ($Revert) {
$Scripts = @("enable-game-bar-dvr.reg")
}
Open-RegFilesCollection -RelativeLocation "src\utils" -Scripts $Scripts -DoneTitle "" -DoneMessage "" -NoDialog

Write-Host "[=][Performance] Enabling game mode..."
Set-ItemProperty -Path "$PathToCUGameBar" -Name "AllowAutoGameMode" -Type DWord -Value 1
Set-ItemProperty -Path "$PathToCUGameBar" -Name "AutoGameModeEnabled" -Type DWord -Value 1

Write-Section -Text "System"
Write-Caption -Text "Display"
Write-Host "[+][Privacy] Enable Hardware Accelerated GPU Scheduling... (Windows 10 20H1+ - Needs Restart)"
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers" -Name "HwSchMode" -Type DWord -Value 2

Write-Host "$($EnableStatus[2]) SysMain/Superfetch..."
# As SysMain was already disabled on the Services, just need to remove it's key
# [@] (0 = Disable SysMain, 1 = Enable when program is launched, 2 = Enable on Boot, 3 = Enable on everything)
Set-ItemProperty -Path "$PathToLMPrefetchParams" -Name "EnableSuperfetch" -Type DWord -Value $Zero

Write-Host "$($EnableStatus[0]) Remote Assistance..."
Write-Host "$($EnableStatus[2]) Remote Assistance..."
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance" -Name "fAllowToGetHelp" -Type DWord -Value $Zero

Write-Host "[-][Priv&Perf] Disabling Ndu High RAM Usage..."
Write-Host "[-][Performance] Disabling Ndu High RAM Usage..."
Set-ItemProperty -Path "HKLM:\SYSTEM\ControlSet001\Services\Ndu" -Name "Start" -Type DWord -Value 4

# Details: https://www.tenforums.com/tutorials/94628-change-split-threshold-svchost-exe-windows-10-a.html
# Will reduce Processes number considerably on > 4GB of RAM systems
Write-Host "[+][Priv&Perf] Setting SVCHost to match RAM size..."
Write-Host "[+][Performance] Setting SVCHost to match RAM size..."
$RamInKB = (Get-CimInstance -ClassName Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum).Sum / 1KB
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control" -Name "SvcHostSplitThresholdInKB" -Type DWord -Value $RamInKB

Write-Host "[+][Priv&Perf] Unlimiting your network bandwidth for all your system..." # Based on this Chris Titus video: https://youtu.be/7u1miYJmJ_4
Write-Host "[+][Performance] Unlimiting your network bandwidth for all your system..." # Based on this Chris Titus video: https://youtu.be/7u1miYJmJ_4
If (!(Test-Path "$PathToLMPoliciesPsched")) {
New-Item -Path "$PathToLMPoliciesPsched" -Force | Out-Null
}
Set-ItemProperty -Path "$PathToLMPoliciesPsched" -Name "NonBestEffortLimit" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile" -Name "NetworkThrottlingIndex" -Type DWord -Value 0xffffffff

Write-Host "[=][Priv&Perf] Enabling Windows Store apps Automatic Updates..."
Write-Host "[=][Performance] Enabling Windows Store apps Automatic Updates..."
If (!(Test-Path "$PathToLMPoliciesWindowsStore")) {
New-Item -Path "$PathToLMPoliciesWindowsStore" -Force | Out-Null
}
Expand All @@ -408,16 +402,16 @@ function Optimize-PrivacyAndPerformance() {
}

Write-Section -Text "Power Plan Tweaks"
Write-Host "[+][Priv&Perf] Setting Power Plan to High Performance..."
Write-Host "[+][Performance] Setting Power Plan to High Performance..."
powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c

# Found on the registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\Default\PowerSchemes
Write-Host "[+][Priv&Perf] Enabling (Not setting) the Ultimate Performance Power Plan..."
Write-Host "[+][Performance] Enabling (Not setting) the Ultimate Performance Power Plan..."
powercfg -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61

Write-Section -Text "Network & Internet"
Write-Caption -Text "Proxy"
Write-Host "[-][Priv&Perf] Fixing Edge slowdown by NOT Automatically Detecting Settings..."
Write-Host "[-][Performance] Fixing Edge slowdown by NOT Automatically Detecting Settings..."
# Code from: https://www.reddit.com/r/PowerShell/comments/5iarip/set_proxy_settings_to_automatically_detect/?utm_source=share&utm_medium=web2x&context=3
$key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections'
$data = (Get-ItemProperty -Path $key -Name DefaultConnectionSettings).DefaultConnectionSettings
Expand Down
1 change: 1 addition & 0 deletions src/scripts/optimize-scheduled-tasks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ function Optimize-ScheduledTasksList() {
}

function Main() {
# List all Scheduled Tasks: Get-ScheduledTask | Select-Object -Property State, TaskPath, TaskName | Sort-Object State, TaskPath, TaskName | Out-GridView
If (!($Revert)) {
Optimize-ScheduledTasksList # Disable Scheduled Tasks that causes slowdowns
}
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/optimize-services.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function Optimize-RunningServicesList() {
}

function Main() {
# List all services: Get-Service | Select-Object StartType, Status, Name, DisplayName, ServiceType | Sort-Object StartType | Out-GridView
# List all services: Get-Service | Select-Object StartType, Status, Name, DisplayName, ServiceType | Sort-Object StartType, Status, Name | Out-GridView
If (!($Revert)) {
Optimize-RunningServicesList # Enable essential Services and Disable bloating Services
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Import-Module -DisableNameChecking $PSScriptRoot\..\lib\"title-templates.psm1"

# Adapted from: https://github.com/ChrisTitusTech/win10script/pull/131/files

function Optimize-OptionalFeaturesList() {
function Optimize-WindowsFeaturesList() {
[CmdletBinding()]
param (
[Switch] $Revert,
Expand Down Expand Up @@ -37,8 +37,6 @@ function Optimize-OptionalFeaturesList() {
}

Write-Title -Text "Uninstall features from Windows"
# Dism /online /Get-Features #/Format:Table # To find all features
# Get-WindowsOptionalFeature -Online

$DisableFeatures = @(
"FaxServicesClientPackage" # Windows Fax and Scan
Expand Down Expand Up @@ -89,11 +87,14 @@ function Optimize-OptionalFeaturesList() {
}

function Main() {
# List all Optional Features: Get-WindowsOptionalFeature -Online | Select-Object -Property State, FeatureName | Sort-Object State, FeatureName | Out-GridView
# List all Windows Packages: Get-WindowsPackage -Online | Select-Object -Property ReleaseType, PackageName, PackageState, InstallTime | Sort-Object ReleaseType, PackageState, PackageName | Out-GridView
# List all Windows Capabilities: Get-WindowsCapability -Online | Select-Object -Property State, Name | Sort-Object State, Name | Out-GridView
If (!($Revert)) {
Optimize-OptionalFeaturesList # Disable useless features and Enable features claimed as Optional on Windows, but actually, they are useful
Optimize-WindowsFeaturesList # Disable useless features and Enable features claimed as Optional on Windows, but actually, they are useful
}
Else {
Optimize-OptionalFeaturesList -Revert
Optimize-WindowsFeaturesList -Revert
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/scripts/personal-tweaks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ function Register-PersonalTweaksList() {
}
Open-RegFilesCollection -RelativeLocation "src\utils" -Scripts $Scripts -DoneTitle "" -DoneMessage "" -NoDialog

# Show Task Manager details - Applicable to 1607 and later - Although this functionality exist even in earlier versions, the Task Manager's behavior is different there and is not compatible with this tweak
Write-Host "[+][Personal] Showing task manager details..."
$taskmgr = Start-Process -WindowStyle Hidden -FilePath taskmgr.exe -PassThru
Do {
Start-Sleep -Milliseconds 100
$preferences = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -ErrorAction SilentlyContinue
} Until ($preferences)
Stop-Process $taskmgr
$preferences.Preferences[28] = 0
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -Type Binary -Value $preferences.Preferences

Write-Section -Text "Windows Explorer Tweaks"
Write-Host "[-][Personal] Hiding Quick Access from Windows Explorer..."
Set-ItemProperty -Path "$PathToCUExplorer" -Name "ShowFrequent" -Type DWord -Value $Zero
Expand Down
2 changes: 2 additions & 0 deletions src/scripts/remove-bloatware-apps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ function Remove-BloatwareAppsList() {
}

function Main() {
# List all Packages: Get-AppxPackage | Select-Object -Property Name, Architecture, Version, Publisher, InstallLocation, IsFramework, IsBundle, IsDevelopmentMode, NonRemovable, SignatureKind, Status, Dependencies | Sort-Object Publisher, Name, Architecture | Out-GridView
# List all Provisioned Packages: Get-AppxProvisionedPackage -Online | Select-Object -Property DisplayName, Architecture, Version, PublisherId, InstallLocation, Region, ResourceId | Sort-Object PublisherId, DisplayName, Architecture | Out-GridView
Remove-BloatwareAppsList # Remove the main Bloat from Pre-installed Apps
}

Expand Down

0 comments on commit 0803cb1

Please sign in to comment.