Postanowiłem porozmawiać z kolegą Ai w kwestii co z tym zrobić
Kod: Zaznacz cały
# Uruchom jako administrator!
# Czyszczenie folderu systemowego Temp
$systemTempPaths = @("C:\Windows\Temp", "C:\Temp")
foreach ($path in $systemTempPaths) {
if (Test-Path $path) {
Write-Output "Czyszczenie $path..."
Get-ChildItem -Path $path -Recurse -Force -ErrorAction SilentlyContinue | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
}
}
# Pobieranie profili użytkowników
$userProfiles = Get-ChildItem 'C:\Users' | Where-Object {
$_.PSIsContainer -and
$_.Name -notin @("Default", "Default User", "Public", "All Users")
}
# Czyszczenie Temp w profilach użytkowników
foreach ($profile in $userProfiles) {
$tempPath = "C:\Users\$($profile.Name)\AppData\Local\Temp"
if (Test-Path $tempPath) {
Write-Output "Czyszczenie $tempPath..."
Get-ChildItem -Path $tempPath -Recurse -Force -ErrorAction SilentlyContinue | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
}
}
Write-Output "Czyszczenie zakończone."plik należy zapisać jako .ps1 w formacie UTF-8 BOM
i można sobie go potem dodać do harmonogramu zadań np. albo uruchamiać z poziomu powłoki.
