Created
March 28, 2020 16:28
-
-
Save pknowledge/3e56ecab7eccc1e425893de0fb6def30 to your computer and use it in GitHub Desktop.
Clean PC using powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$objShell = New-Object -ComObject Shell.Application | |
$objFolder = $objShell.Namespace(0xA) | |
$WinTemp = "c:\Windows\Temp\*" | |
#1# Empty Recycle Bin # | |
write-Host "Emptying Recycle Bin." -ForegroundColor Cyan | |
$objFolder.items() | %{ remove-item $_.path -Recurse -Confirm:$false} | |
#2# Remove Temp | |
write-Host "Removing Temp" -ForegroundColor Green | |
Set-Location “C:\Windows\Temp” | |
Remove-Item * -Recurse -Force -ErrorAction SilentlyContinue | |
Set-Location “C:\Windows\Prefetch” | |
Remove-Item * -Recurse -Force -ErrorAction SilentlyContinue | |
Set-Location “C:\Documents and Settings” | |
Remove-Item “.\*\Local Settings\temp\*” -Recurse -Force -ErrorAction SilentlyContinue | |
Set-Location “C:\Users” | |
Remove-Item “.\*\Appdata\Local\Temp\*” -Recurse -Force -ErrorAction SilentlyContinue | |
#3# Running Disk Clean up Tool | |
write-Host "Finally now , Running Windows disk Clean up Tool" -ForegroundColor Cyan | |
cleanmgr /sagerun:1 | out-Null | |
$([char]7) | |
Sleep 3 | |
write-Host "I finished the cleanup task,Bye Bye " -ForegroundColor Yellow | |
Sleep 3 | |
##### End of the Script ##### |
This caused me not to be able to log back into my windows account. I keep getting device offline error
effectivement la commande
Remove-Item “.*\Local Settings\temp*” -Recurse -Force -ErrorAction SilentlyContinue
Set-Location “C:\Users”
Remove-Item “.\*\Appdata\Local\Temp\*” -Recurse -Force -ErrorAction SilentlyContinue
supprime le profil
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
came from programming knowledge yt channel