Windows 11 Clear Temp Files ((install)) «Limited Time»

function Get-FolderSize param($Path) try $colItems = Get-ChildItem $Path -Recurse -Force -ErrorAction SilentlyContinue catch return 0

function Clean-Folder param($Path) $originalSize = Get-FolderSize $Path try Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $newSize = Get-FolderSize $Path return [math]::Round($originalSize - $newSize, 2) catch return 0 windows 11 clear temp files

Write-Host "Scheduled task '$taskName' created (runs every Sunday at 3 AM)" -ForegroundColor Green if ($args -contains "-Silent") Clear-TempFiles -Silent elseif ($args -contains "-CreateShortcut") Create-Shortcut elseif ($args -contains "-CreateTask") Create-ScheduledTask else # Show menu Write-Host "" Write-Host "Options:" -ForegroundColor Cyan Write-Host "1. Run Cleaner Now" Write-Host "2. Create Desktop Shortcut" Write-Host "3. Create Scheduled Task (Weekly)" Write-Host "4. Exit" Write-Host "" Create Scheduled Task (Weekly)" Write-Host "4

foreach ($loc in $locations) if ($loc.Path -eq "RecycleBin") # Handle Recycle Bin separately $size = Get-RecycleBinSize if (-not $Silent) Write-Host "Checking $($loc.Name)..." -ForegroundColor Yellow if (-not $Silent) Write-Host " Size: $(Format-FileSize $size)" -ForegroundColor Gray if ($size -gt 0 -and (-not $Silent)) $confirm = Read-Host " Clear Recycle Bin? (Y/N)" if ($confirm -eq 'Y') Clear-RecycleBin -Force -ErrorAction SilentlyContinue $totalFreed += $size $results += [PSCustomObject]@Location = $loc.Name; Freed = $size if (-not $Silent) Write-Host " ✓ Cleared $(Format-FileSize $size)" -ForegroundColor Green elseif ($size -gt 0 -and $Silent) Clear-RecycleBin -Force -ErrorAction SilentlyContinue $totalFreed += $size elseif (Test-Path $loc.Path) $size = Get-FolderSize $loc.Path if (-not $Silent) Write-Host "Checking $($loc.Name)..." -ForegroundColor Yellow if (-not $Silent) Write-Host " Size: $(Format-FileSize $size)" -ForegroundColor Gray if ($size -gt 0 -and (-not $Silent)) $confirm = Read-Host " Clear this folder? (Y/N/A - All)" if ($confirm -eq 'Y' -or $confirm -eq 'A') $freed = Clean-Folder $loc.Path $totalFreed += $freed $results += [PSCustomObject]@Location = $loc.Name; Freed = $freed if (-not $Silent) Write-Host " ✓ Cleared $(Format-FileSize $freed)" -ForegroundColor Green if ($confirm -eq 'A') $Silent = $true elseif ($size -gt 0 -and $Silent) $freed = Clean-Folder $loc.Path $totalFreed += $freed else if (-not $Silent) Write-Host "Skipping $($loc.Name) (not found)" -ForegroundColor DarkGray if (-not $Silent) Write-Host "" (Y/N/A - All)" if ($confirm -eq 'Y' -or

function Create-Shortcut $shortcutPath = "$env:USERPROFILE\Desktop\Clear Temp Files.lnk" $scriptPath = $MyInvocation.MyCommand.Path

# Run in PowerShell as Administrator Get-ChildItem -Path "$env:TEMP","$env:SystemRoot\Temp","$env:SystemRoot\Prefetch" -Recurse -Force -ErrorAction SilentlyContinue | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue; Clear-RecycleBin -Force Method 3: Batch File (Traditional) @echo off title Windows 11 Temp Cleaner color 0A echo ======================================== echo Windows 11 Temporary Files Cleaner echo ======================================== echo. echo Cleaning user temp... del /q /f /s "%TEMP%*" > nul 2>&1 rmdir /q /s "%TEMP%" > nul 2>&1 mkdir "%TEMP%" > nul 2>&1

Scroll al inicio