Files
Crapfixer/plugins/Restart Explorer.ps1
T
Peter 2e2b4fd5c8 refactor(plugins): improve script readability and admin checks
- Standardized spacing and formatting in CFEnhancer.txt
- Added admin privilege checks and warnings in Restart Explorer.ps1, Uninstall OneDrive.ps1, Restore all built-in apps.ps1
- Simplified admin check logic in Create Restore Point.ps1
- Enhanced success reporting in Restore all built-in apps.ps1
- Grouped apps by Microsoft and third-party in Remove default apps.ps1
2025-05-18 00:05:19 +10:00

27 lines
896 B
PowerShell

#Requires -RunAsAdministrator
# Check if running as Administrator
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Warning "This script is recommended to be run as Administrator for best results."
# Decide if you want to force exit or just warn
# exit # Uncomment to force admin
}
# Function to show a message box
function Show-MessageBox {
param (
[string]$message,
[string]$title = "Information"
)
Add-Type -AssemblyName PresentationFramework
[System.Windows.MessageBox]::Show($message, $title)
}
# Stop Windows Explorer
Stop-Process -Name explorer -Force
# Start Windows Explorer
Start-Process explorer
# Show message box
Show-MessageBox -message "Windows Explorer has been restarted successfully." -title "Crapfixer"