Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ########################################################################################################################
- #=====[ Clean Manager ]=====#
- ########################################################################################################################
- #=====[ Creating Clean Manager Sageset ]=====#
- $Flags = "StateFlags0110"
- $Prefix_RegHive = "Registry::HKEY_LOCAL_MACHINE"
- $Prefix_RegPath = "HKLM:"
- $RegClnPath = "\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches"
- $RegHive = $Prefix_RegHive + $RegClnPath
- $RegPath = $Prefix_RegPath + $RegClnPath
- $RegistryArray= @(
- "Active Setup Temp Folders" # Temporary Setup Files
- "BranchCache" # Branch Cache (WAN bandwidth optimization)
- #"Content Indexer Cleaner" # Catalog Files for the Content Indexer (deletes all files in the folder c:\catalog.wci)
- "Delivery Optimization Files" # Delivery Optimization Files (service to share bandwidth for uploading Windows updates)
- "Diagnostic Data Viewer database Files" # Diagnostic data viewer database files (Windows app that sends data to Microsoft)
- "D3D Shader Cache" # Direct X Shader cache (graphics cache, clearing this can can speed up application load time.)
- "Downloaded Program Files" # Downloaded Program Files (ActiveX controls and Java applets downloaded from the Internet)
- #"Downloads Folder" # Downloads Folder (Automatically emptying this is probably a bad idea.)
- "Internet Cache Files" # Temporary Internet Files
- #"Language Pack" # Language resources Files (unused languages and keyboard layouts)
- #"Offline Pages Files" # Offline Files (Web pages)
- "Old ChkDsk Files" # Old ChkDsk Files
- #"Recycle Bin" # Recycle Bin Automatically emptying the Recycle Bin is almost never a good idea.
- #"RetailDemo Offline Content" # Retail Demo
- "ServicePack Cleanup" # Update package Backup Files (old versions)
- "Setup Log Files" # Setup Log files (software install logs)
- "System error memory dump files" # System Error memory dump files (These can be very large if the system has crashed)
- "System error minidump files" # System Error minidump files (smaller memory crash dumps)
- "Temporary Files" # Temporary Files (%Windir%\Temp and %Windir%\Logs)
- "Update Cleanup" # Windows Update Cleanup (old system files not migrated during a Windows Upgrade)
- #"User file versions" # User file history (Settings > Update & Security > Backup.)
- "Thumbnail Cache" # Thumbnails (Explorer will recreate thumbnails as each folder is viewed.)
- "Windows Defender" # Windows Defender Antivirus
- "Windows Error Reporting Files" # Windows error reports and feedback diagnostics
- "Windows Upgrade Log Files" # Windows Upgrade log files
- )
- foreach ($Key in $RegistryArray) {
- $SNFlags = $null ; $SNData = $null
- $RegDirHive = $RegHive + "\" + $Key
- $RegDirPath = $RegPath + "\" + $Key
- if( Test-Path -Path $RegDirPath ){
- $Registrykeys = Get-Item -Path $RegDirPath
- $RegistryData = $Registrykeys | Select-Object -ExpandProperty Property | ForEach-Object {
- $name = $_
- $data = "" | Select-Object -Property Name, Path, Type, Data #creates an empty
- $data.Name = $name
- #$data.Type = $Registrykeys.GetValueKind($name)
- $data.Data = $Registrykeys.GetValue($name)
- $data.Path = "Registry::$Registrykeys"
- $data
- }
- $RegistryData | ForEach-Object {
- if( $_.Name -Like "StateFlags*" ) {
- $SNFlags = $_.Name
- $SNData = $_.Data
- $SNPath = $_.Path } }
- if( Test-Path -Path $SNPath ){
- $SetPath = $SNPath + "\" + $SNFlags
- $SetDynPath = $SNPath + "\" + $SNFlags
- $defFlag = (Get-ItemProperty -Path $SNPath | Select-Object -ExpandProperty $Value).$SNFlags
- if( $defFlag -Eq "2" ){ <# No Action Needed #> } else {
- New-Item -Path "$RegDirPath" | Out-Null -EA SilentlyContinue
- New-ItemProperty -Path "$RegDirPath" -Type DWord -Name "$Flags" -Value "2" -Force -EA SilentlyContinue }
- } else {
- New-Item -Path "$RegDirPath" | Out-Null -EA SilentlyContinue
- New-ItemProperty -Path "$RegDirPath" -Type DWord -Name "$Flags" -Value "2" -Force -EA SilentlyContinue
- }
- } else {
- New-Item -Path "$RegDirPath" | Out-Null -EA SilentlyContinue
- New-ItemProperty -Path "$RegDirPath" -Type DWord -Name "$Flags" -Value "2" -Force -EA SilentlyContinue
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement