z230
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
# =====================================================================
|
||||
# clean_windows_temp_v1.0_2026-06-10.ps1
|
||||
# Verze: 1.0 | Datum: 2026-06-10
|
||||
# Popis: Vyčistí C:\Windows\Temp a C:\Windows\SoftwareDistribution\Download
|
||||
# (cache Windows Update). Vyžaduje spuštění JAKO SPRÁVCE.
|
||||
# Zastaví službu Windows Update, smaže cache, službu znovu spustí.
|
||||
# =====================================================================
|
||||
#Requires -RunAsAdministrator
|
||||
|
||||
$before = (Get-PSDrive C).Free
|
||||
|
||||
Write-Host "Mažu C:\Windows\Temp ..."
|
||||
Get-ChildItem 'C:\Windows\Temp' -Force -ErrorAction SilentlyContinue |
|
||||
Remove-Item -Recurse -Force -Confirm:$false -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Host "Zastavuji službu Windows Update ..."
|
||||
Stop-Service wuauserv -Force -ErrorAction SilentlyContinue
|
||||
Stop-Service bits -Force -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Host "Mažu C:\Windows\SoftwareDistribution\Download ..."
|
||||
Get-ChildItem 'C:\Windows\SoftwareDistribution\Download' -Force -ErrorAction SilentlyContinue |
|
||||
Remove-Item -Recurse -Force -Confirm:$false -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Host "Spouštím služby zpět ..."
|
||||
Start-Service bits -ErrorAction SilentlyContinue
|
||||
Start-Service wuauserv -ErrorAction SilentlyContinue
|
||||
|
||||
$after = (Get-PSDrive C).Free
|
||||
Write-Host ("Uvolněno: {0:N2} GB | Volno celkem: {1:N2} GB" -f (($after-$before)/1GB), ($after/1GB))
|
||||
Read-Host "Hotovo - Enter pro zavření"
|
||||
@@ -0,0 +1,27 @@
|
||||
# =====================================================================
|
||||
# clean_windows_temp_v1.1_2026-06-10.ps1
|
||||
# Verze: 1.1 | Datum: 2026-06-10
|
||||
# Popis: Vyčistí C:\Windows\Temp. Vyžaduje spuštění JAKO SPRÁVCE.
|
||||
# v1.1: před mazáním převezme vlastnictví (takeown) a přidá
|
||||
# Administrators plná práva (icacls) — v1.0 selhala na ACL
|
||||
# souborů wct*.tmp vlastněných systémovým účtem.
|
||||
# (SoftwareDistribution\Download už vyčistila v1.0.)
|
||||
# =====================================================================
|
||||
#Requires -RunAsAdministrator
|
||||
|
||||
$before = (Get-PSDrive C).Free
|
||||
|
||||
Write-Host "Prebiram vlastnictvi C:\Windows\Temp (muze trvat par minut) ..."
|
||||
takeown /F 'C:\Windows\Temp' /R /D Y | Out-Null
|
||||
icacls 'C:\Windows\Temp' /grant 'Administrators:(OI)(CI)F' /T /C /Q | Out-Null
|
||||
|
||||
Write-Host "Mazu obsah C:\Windows\Temp ..."
|
||||
Get-ChildItem 'C:\Windows\Temp' -Force -ErrorAction SilentlyContinue |
|
||||
Remove-Item -Recurse -Force -Confirm:$false -ErrorAction SilentlyContinue
|
||||
|
||||
$left = (Get-ChildItem 'C:\Windows\Temp' -Recurse -Force -File -ErrorAction SilentlyContinue |
|
||||
Measure-Object Length -Sum).Sum
|
||||
$after = (Get-PSDrive C).Free
|
||||
Write-Host ("Uvolneno: {0:N2} GB | Zbyva v Temp: {1:N2} GB | Volno celkem: {2:N2} GB" -f `
|
||||
(($after-$before)/1GB), ($left/1GB), ($after/1GB))
|
||||
Read-Host "Hotovo - Enter pro zavreni"
|
||||
Reference in New Issue
Block a user