Skip to content

Commit

Permalink
Finalized V4.4 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivamXD6 committed Nov 13, 2024
1 parent 676ca86 commit fea4af5
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 187 deletions.
166 changes: 74 additions & 92 deletions Add-More-Features.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -334,23 +334,16 @@ Create-File -fileContent $notification -fileName 'Enable - Notifications and Bac
# Optimizations
# Cleanup
$cleanup = @'
# Ensure the script runs as Administrator
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Output "Please run this script as Administrator."
Pause
Exit
}
# Kill Process, Ignore Errors and Continue
$ErrorActionPreference = 'SilentlyContinue'
Get-Process -Name cleanmgr -EA 0 | Stop-Process -Force -EA 0
# Function to display sections
function Show-Message ($message) {
Write-Output "==========================================="
Write-Output " $message"
Write-Output "==========================================="
Start-Sleep -Seconds 2
Write-Output "==========================================="
Write-Output " $message"
Write-Output "==========================================="
Start-Sleep -Seconds 1
}
# Show initial disk space
Expand All @@ -359,96 +352,95 @@ $initialFreeGB = [math]::Round($initialFreeMB / 1024, 2)
Show-Message "Using Disk Cleanup with custom configuration"
$volumeCache = @{
"Active Setup Temp Folders" = 2
"BranchCache" = 2
"Content Indexer Cleaner" = 2
"Delivery Optimization Files" = 2
"Device Driver Packages" = 2
"Diagnostic Data Viewer database files" = 2
"Downloaded Program Files" = 2
"Feedback Hub Archive log files" = 2
"Internet Cache Files" = 2
"Language Pack" = 2
"Offline Pages Files" = 2
"Old ChkDsk Files" = 2
"Recycle Bin" = 2
"RetailDemo Offline Content" = 2
"Setup Log Files" = 2
"System error memory dump files" = 2
"System error minidump files" = 2
"Temporary Files" = 2
"Temporary Setup Files" = 2
"Temporary Sync Files" = 2
"Update Cleanup" = 2
"Upgrade Discarded Files" = 2
"User file versions" = 2
"Windows Defender" = 2
"Windows Error Reporting Files" = 2
"Windows ESD installation files" = 2
"Windows Reset Log Files" = 2
"Windows Upgrade Log Files" = 2
"Active Setup Temp Folders" = 2
"BranchCache" = 2
"Content Indexer Cleaner" = 2
"Delivery Optimization Files" = 2
"Device Driver Packages" = 2
"Diagnostic Data Viewer database files" = 2
"Downloaded Program Files" = 2
"Feedback Hub Archive log files" = 2
"Internet Cache Files" = 2
"Language Pack" = 2
"Offline Pages Files" = 2
"Old ChkDsk Files" = 2
"Recycle Bin" = 2
"RetailDemo Offline Content" = 2
"Setup Log Files" = 2
"System error memory dump files" = 2
"System error minidump files" = 2
"Temporary Files" = 2
"Temporary Setup Files" = 2
"Temporary Sync Files" = 2
"Update Cleanup" = 2
"Upgrade Discarded Files" = 2
"User file versions" = 2
"Windows Defender" = 2
"Windows Error Reporting Files" = 2
"Windows ESD installation files" = 2
"Windows Reset Log Files" = 2
"Windows Upgrade Log Files" = 2
}
$registryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches"
foreach ($item in $volumeCache.GetEnumerator()) {
$keyPath = Join-Path $registryPath $item.Key
if (Test-Path $keyPath) {
New-ItemProperty -Path $keyPath -Name StateFlags1337 -Value $item.Value -PropertyType DWord | Out-Null
}
$keyPath = Join-Path $registryPath $item.Key
if (Test-Path $keyPath) {
New-ItemProperty -Path $keyPath -Name StateFlags1337 -Value $item.Value -PropertyType DWord | Out-Null
}
}
Start-Process -FilePath "$env:SystemRoot\system32\cleanmgr.exe" -ArgumentList "/sagerun:1337" -Wait:$false
Show-Message "Cleaning up leftovers"
$foldersToRemove = @(
"CbsTemp",
"Logs",
"Panther",
"Prefetch",
"SoftwareDistribution",
"System32\LogFiles",
"System32\LogFiles\WMI",
"System32\SleepStudy",
"System32\sru",
"System32\WDI\LogFiles",
"System32\winevt\Logs",
"SystemTemp",
"Temp"
"C:\CbsTemp",
"C:\Logs",
"C:\Panther",
"C:\Prefetch",
"C:\ProgramData\Microsoft\Windows Defender\Scans",
"C:\Program Files (x86)\Microsoft\EdgeUpdate\Download",
"C:\SoftwareDistribution",
"C:\System32\LogFiles",
"C:\System32\LogFiles\WMI",
"C:\System32\SleepStudy",
"C:\System32\sru",
"C:\System32\WDI\LogFiles",
"C:\System32\winevt\Logs",
"C:\SystemTemp",
"C:\Temp"
)
foreach ($folderName in $foldersToRemove) {
$folderPath = Join-Path $env:SystemRoot $folderName
if (Test-Path $folderPath) {
Remove-Item -Path "$folderPath\*" -Force -Recurse | Out-Null
foreach ($folderPath in $foldersToRemove) {
if (Test-Path $folderPath) {
try {
& takeown /F $folderPath /R /D Y *> $null
& icacls $folderPath /grant Administrators:F /T *> $null
Write-Output " - Deleted Files from Folder: $($folderPath)"
Remove-Item -Path "$folderPath\*" -Force -Recurse
}
catch {}
}
}
$fileTypes = @("C:\*.tmp", "C:\*.log", "C:\*.chk", "C:\*.old")
foreach ($path in $fileTypes) {
Get-ChildItem -Path $path -Recurse -Force | ForEach-Object {
try {
Remove-Item -Path $_.FullName -Force -Recurse
Write-Output " - Deleted File: $($_.FullName)"
} catch {}
}
}
Remove-Item -Path "C:\Program Files\WindowsApps\MicrosoftWindows.Client.WebExperience*" -Recurse -Force
Show-Message "Cleaning up %TEMP% and Log Files"
Get-ChildItem -Path "$env:TEMP" | Remove-Item -Recurse -Force
Get-ChildItem -Path "$env:SystemRoot" -Filter *.log -File -Recurse -Force | Remove-Item -Recurse -Force | Out-Null
Show-Message "Cleaning up Event Logs"
Get-EventLog -LogName * | ForEach-Object { Clear-EventLog $_.Log }
# Run DISM Component Cleanup
Show-Message "Cleaning up WinSxS components"
Dism /online /Cleanup-Image /StartComponentCleanup /ResetBase
# Clean Edge Update Downloads
Show-Message "Cleaning up EdgeUpdate Downloads"
$edgeUpdatePath = ${env:ProgramFiles(x86)} + "\Microsoft\EdgeUpdate\Download"
if (Test-Path -Path $edgeUpdatePath) {
Remove-Item -Path $edgeUpdatePath -Force -Recurse | Out-Null
}
# Clean Empty Folders
Show-Message "Cleaning Empty Folders"
Get-ChildItem -Directory -Path "C:\" -Recurse -ErrorAction SilentlyContinue |
Where-Object { try { ($_.GetFiles().Count -eq 0) -and ($_.GetDirectories().Count -eq 0) } catch { $false } } |
ForEach-Object {
try {
Remove-Item $_.FullName -Force -Recurse -ErrorAction SilentlyContinue
Write-Output "Deleted Empty Folder: $($_.FullName)"
} catch {}
Get-ChildItem -Directory -Path "C:\" -Recurse | Where-Object { try { ($_.GetFiles().Count -eq 0) -and ($_.GetDirectories().Count -eq 0) } catch { $false } } | ForEach-Object {
try {
Remove-Item $_.FullName -Force -Recurse
Write-Output " - Deleted Empty Folder: $($_.FullName)"
} catch {}
}
# Clean System Restore Points
Expand All @@ -460,11 +452,9 @@ $finalFreeMB = (Get-PSDrive -Name C).Free / 1MB
$finalFreeGB = [math]::Round($finalFreeMB / 1024, 2)
$freedSpaceMB = $finalFreeMB - $initialFreeMB
$freedSpaceGB = [math]::Round($freedSpaceMB / 1024, 2)
Show-Message "Before Cleanup: $initialFreeMB MB ($initialFreeGB GB) Free"
Show-Message "After Cleanup: $finalFreeMB MB ($finalFreeGB GB) Free"
Show-Message "Freed Space: $freedSpaceMB MB ($freedSpaceGB GB)"
Pause
'@
Create-File -fileContent $cleanup -fileName 'Cleanup.ps1' -fileDirectory $optimizationPath
Expand Down Expand Up @@ -496,19 +486,11 @@ pause & exit
set reg1="HKCU\System\GameConfigStore"
set reg2="HKLM\SOFTWARE\Policies\Microsoft\Windows\GameDVR"
if "%~n0"=="Enable - GameDVR" (
reg add %reg1% /v GameDVR_FSEBehavior /t REG_DWORD /d 0 /f
reg add %reg1% /v GameDVR_Enabled /t REG_DWORD /d 1 /f
reg add %reg1% /v GameDVR_DXGIHonorFSEWindowsCompatible /t REG_DWORD /d 0 /f
reg add %reg1% /v GameDVR_HonorUserFSEBehaviorMode /t REG_DWORD /d 0 /f
reg add %reg1% /v GameDVR_EFSEFeatureFlags /t REG_DWORD /d 1 /f
reg add %reg2% /v AllowGameDVR /t REG_DWORD /d 1 /f
ren "%~dpnx0" "Disable - GameDVR.cmd"
) else (
reg delete %reg1% /v GameDVR_FSEBehavior /f
reg delete %reg1% /v GameDVR_Enabled /f
reg delete %reg1% /v GameDVR_DXGIHonorFSEWindowsCompatible /f
reg delete %reg1% /v GameDVR_HonorUserFSEBehaviorMode /f
reg delete %reg1% /v GameDVR_EFSEFeatureFlags /f
reg delete %reg2% /v AllowGameDVR /f
ren "%~dpnx0" "Enable - GameDVR.cmd"
)
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOGS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# Changelogs - V4.4
## Answer File Changes
- *Removed Pins and One Drive from the Start Menu (in Windows 10), also made some minor changes.
- *Changed Locations of some files of the Shivaay folder.
- Fixed Clipboard Delay (Thanks to Aftab for pointing out this issue)
- *Not Restoring Legacy Photo Viewer by default.
- *Using My Safemode approach to disable defender as it's a more efficient way.
- *Disabled Core Isolation again by default as it reduces CPU performance by 5% (in my case).
- *Removed additional commands for disabling various components, as the running folder scripts can handle it as well.
- Removed BranchReadinessLevel policy registry looks like it doesn't do anything.
- Removed Smart Screen script (I'll work on it later).

## Shivaay Folder Changes
- Updated Cleanup Script (Fully Changed Cleaning methods and converted it into a Powershell script)
- Updated Defender Script (To automatically reboot to normal mode after Toggling defender)
- *Included Compact OS (as I use this on every Installation)

## Additional Features Script Changes
- Added Script to Restore or Remove Legacy Photo Viewer in System Management.

## Update Script Changes
- Included everything from above, except the ones with an asterisk (*)

# Changelogs - V4.3
## Answer File Changes
- Removed One registry for modifying OEM Info.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 🔮 Optimize Windows
[![Version](https://img.shields.io/badge/Version-V4.3%20-2D9F2D?style=for-the-badge&logo=github&logoColor=white)](https://github.com/ShivamXD6/Optimize-Windows/releases/latest)
[![Version](https://img.shields.io/badge/Version-V4.4%20-2D9F2D?style=for-the-badge&logo=github&logoColor=white)](https://github.com/ShivamXD6/Optimize-Windows/releases/latest)
[![User Base](https://img.shields.io/github/downloads/ShivamXD6/Optimize-Windows/total?style=for-the-badge&logo=github&label=User%20Base&link=https%3A%2F%2Fgithub.com%2FShivamXD6%2FOptimize-Windows%2Freleases%2Flatest)](https://github.com/ShivamXD6/Optimize-Windows/releases/latest)
[![License](https://img.shields.io/badge/License-GPL%20v3-0078D4?style=for-the-badge&logo=open-source-initiative&logoColor=white)](https://github.com/ShivamXD6/Optimize-Windows/blob/main/LICENSE)
![Last Updated](https://img.shields.io/github/last-commit/ShivamXD6/Optimize-Windows?style=for-the-badge&color=6A5ACD&label=Last%20Updated)
Expand Down Expand Up @@ -111,7 +111,6 @@
- 🔍 Toggle Search Indexing
- 🎥 Toggle GameDVR
- 🔒 *Toggle Biometrics (Fingerprint and Face Unlock)
- 💿 *Toggle Compact OS (Free up space by compressing Windows Binaries)
- 📝 *Configure Shivaay OS (Like change OS name, Folder Location etc)

#### **Optimizations**
Expand All @@ -120,6 +119,7 @@
- 🧹 Cleanup Script to clean unnecessary files and free up space
- 💽 *Toggle Superfetch/Prefetch
-*Toggle Delivery Optimization
- 💿 Toggle Compact OS (Free up space by compressing Windows Binaries)

#### 🖥️ **User Interface**
- 🖼️ Toggle Gallery and Home
Expand Down
Loading

0 comments on commit fea4af5

Please sign in to comment.