Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Запуск от администратора обязателен
- # Получаем список всех папок профилей пользователей
- $usersPath = "C:\Users"
- $chromeRelativePath = "AppData\Local\Google\Chrome\User Data"
- # Функция для удаления содержимого папки
- function Clear-FolderContents($folderPath) {
- if (Test-Path $folderPath) {
- try {
- Get-ChildItem -Path $folderPath -Recurse -Force | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
- Write-Output "Очищено: $folderPath"
- } catch {
- Write-Warning "Ошибка при удалении содержимого: $folderPath"
- }
- }
- }
- # Обход всех профилей пользователей
- Get-ChildItem $usersPath -Directory | ForEach-Object {
- $userProfile = $_.FullName
- $userChromePath = Join-Path $userProfile $chromeRelativePath
- if (Test-Path $userChromePath) {
- # Перебор всех профилей Chrome: Profile 1, Default, и т.д.
- Get-ChildItem -Path $userChromePath -Directory | ForEach-Object {
- $profilePath = $_.FullName
- $cachePath = Join-Path $profilePath "Cache"
- $codeCachePath = Join-Path $profilePath "Code Cache"
- Clear-FolderContents -folderPath $cachePath
- Clear-FolderContents -folderPath $codeCachePath
- }
- }
- }
- $users = Get-ChildItem "C:\Users" -Directory
- foreach ($user in $users) {
- $tempPath = Join-Path $user.FullName "AppData\Local\Temp"
- if (Test-Path $tempPath) {
- try {
- Get-ChildItem $tempPath -Force -Recurse | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
- Write-Output "Очищено: $tempPath"
- } catch {
- Write-Warning "Ошибка при очистке: $($_.Exception.Message)"
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment