Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Ścieżka do folderu z profilami użytkowników
- $profilesPath = "C:\Users"
- # Ścieżka do folderu "Pulpit" dla wszystkich użytkowników
- $commonDesktopPath = "C:\Users\Public\Desktop"
- # Pobierz wszystkie profile użytkowników
- $profiles = Get-ChildItem -Path $profilesPath
- # Lista nazw programów, których skróty nie będą usuwane
- $excludedShortcuts = @("Visual Studio Code", "Code::Blocks", "GIMP", "JetBrains")
- foreach ($profile in $profiles) {
- # Sprawdź, czy nazwa profilu zawiera "uczeń"
- if ($profile.Name -like "*uczeń*") {
- # Ścieżki do folderów
- $documentsPath = Join-Path -Path $profile.FullName -ChildPath "Documents"
- $desktopPath = Join-Path -Path $profile.FullName -ChildPath "Desktop"
- $downloadsPath = Join-Path -Path $profile.FullName -ChildPath "Downloads"
- # Usuń wszystkie pliki z folderu Dokumenty
- if (Test-Path $documentsPath) {
- Remove-Item -Path "$documentsPath\*" -Recurse -Force -ErrorAction SilentlyContinue
- }
- # Usuń pliki z folderu Pulpit, z wyjątkiem skrótów do wykluczonych programów
- if (Test-Path $desktopPath) {
- $desktopItems = Get-ChildItem -Path $desktopPath
- foreach ($item in $desktopItems) {
- if ($item.PSIsContainer -or ($item.Extension -ne ".lnk")) {
- # Jeśli to nie jest skrót, usuń
- Remove-Item -Path $item.FullName -Recurse -Force -ErrorAction SilentlyContinue
- } else {
- # Sprawdź, czy skrót nie jest jednym z wykluczonych
- $shortcutTarget = (Get-Item $item.FullName).Target
- if ($excludedShortcuts -notcontains $shortcutTarget) {
- Remove-Item -Path $item.FullName -Force -ErrorAction SilentlyContinue
- }
- }
- }
- }
- # Usuń wszystkie pliki z folderu Pobrane
- if (Test-Path $downloadsPath) {
- Remove-Item -Path "$downloadsPath\*" -Recurse -Force -ErrorAction SilentlyContinue
- }
- }
- }
- # Usuń skrót do Uniget z folderu "Pulpit" dla wszystkich użytkowników
- if (Test-Path $commonDesktopPath) {
- $unigetShortcut = Join-Path -Path $commonDesktopPath -ChildPath "UnigetUI.lnk"
- if (Test-Path $unigetShortcut) {
- Remove-Item -Path $unigetShortcut -Force -ErrorAction SilentlyContinue
- }
- }
- # Opróżnij kosz
- $Shell = New-Object -ComObject Shell.Application
- $RecycleBin = $Shell.Namespace(10)
- $RecycleBin.Items() | ForEach-Object { $_.InvokeVerb('delete') }
Add Comment
Please, Sign In to add comment