100 lines
3.6 KiB
PowerShell
100 lines
3.6 KiB
PowerShell
[Console]::OutputEncoding = [Text.Encoding]::UTF8
|
|
$ErrorActionPreference = 'Continue'
|
|
|
|
Write-Host "[*] Adding Computer and Control Panel icons to desktop"
|
|
|
|
# Registry paths for desktop icons
|
|
$desktopIconsPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel"
|
|
$classicIconsPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu"
|
|
|
|
# Icon GUIDs
|
|
$computerGUID = "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" # This PC / Computer
|
|
$controlPanelGUID = "{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}" # Control Panel
|
|
$recycleGUID = "{645FF040-5081-101B-9F08-00AA002F954E}" # Recycle Bin
|
|
$userFilesGUID = "{59031a47-3f72-44a7-89c5-5595fe6b30ee}" # User Files
|
|
$networkGUID = "{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}" # Network
|
|
|
|
Write-Host "[*] Ensuring registry paths exist"
|
|
|
|
# Ensure registry paths exist
|
|
if (-not (Test-Path $desktopIconsPath)) {
|
|
New-Item -Path $desktopIconsPath -Force | Out-Null
|
|
Write-Host " Created registry path: NewStartPanel"
|
|
}
|
|
|
|
if (-not (Test-Path $classicIconsPath)) {
|
|
New-Item -Path $classicIconsPath -Force | Out-Null
|
|
Write-Host " Created registry path: ClassicStartMenu"
|
|
}
|
|
|
|
Write-Host "[*] Current desktop icon status"
|
|
|
|
# Check current status
|
|
$currentIcons = @{
|
|
"Computer" = $computerGUID
|
|
"Control Panel" = $controlPanelGUID
|
|
"Recycle Bin" = $recycleGUID
|
|
"User Files" = $userFilesGUID
|
|
"Network" = $networkGUID
|
|
}
|
|
|
|
foreach ($iconName in $currentIcons.Keys) {
|
|
$guid = $currentIcons[$iconName]
|
|
$value = Get-ItemProperty -Path $desktopIconsPath -Name $guid -ErrorAction SilentlyContinue
|
|
if ($value) {
|
|
$status = if ($value.$guid -eq 0) { "Visible" } else { "Hidden" }
|
|
} else {
|
|
$status = "Default (Hidden)"
|
|
}
|
|
Write-Host " $iconName : $status"
|
|
}
|
|
|
|
Write-Host "[*] Enabling Computer and Control Panel icons"
|
|
|
|
# Enable Computer icon (This PC)
|
|
Set-ItemProperty -Path $desktopIconsPath -Name $computerGUID -Value 0
|
|
Set-ItemProperty -Path $classicIconsPath -Name $computerGUID -Value 0
|
|
Write-Host " Computer (This PC) icon enabled"
|
|
|
|
# Enable Control Panel icon
|
|
Set-ItemProperty -Path $desktopIconsPath -Name $controlPanelGUID -Value 0
|
|
Set-ItemProperty -Path $classicIconsPath -Name $controlPanelGUID -Value 0
|
|
Write-Host " Control Panel icon enabled"
|
|
|
|
# Keep Recycle Bin enabled (it's probably already enabled)
|
|
Set-ItemProperty -Path $desktopIconsPath -Name $recycleGUID -Value 0
|
|
Set-ItemProperty -Path $classicIconsPath -Name $recycleGUID -Value 0
|
|
Write-Host " Recycle Bin icon ensured enabled"
|
|
|
|
Write-Host "[*] Refreshing desktop"
|
|
|
|
# Refresh the desktop to apply changes
|
|
try {
|
|
# Method 1: Use rundll32 to refresh
|
|
& rundll32.exe user32.dll,UpdatePerUserSystemParameters
|
|
|
|
# Method 2: Refresh explorer (more reliable)
|
|
$explorerProcesses = Get-Process explorer -ErrorAction SilentlyContinue
|
|
if ($explorerProcesses) {
|
|
Write-Host " Restarting Explorer to apply changes..."
|
|
Stop-Process -Name explorer -Force
|
|
Start-Sleep -Seconds 2
|
|
Start-Process explorer
|
|
Write-Host " Explorer restarted"
|
|
}
|
|
} catch {
|
|
Write-Host " [!] Could not restart Explorer: $($_.Exception.Message)"
|
|
Write-Host " Please restart Explorer manually or reboot to see changes"
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "[OK] Desktop icons setup complete!"
|
|
Write-Host ""
|
|
Write-Host "Enabled icons:"
|
|
Write-Host "- This PC (Computer)"
|
|
Write-Host "- Control Panel"
|
|
Write-Host "- Recycle Bin"
|
|
Write-Host ""
|
|
Write-Host "If icons don't appear immediately:"
|
|
Write-Host "1. Right-click desktop > Refresh"
|
|
Write-Host "2. Or restart the computer" |