Files
Crapfixer/plugins/Create Restore Point.ps1
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

36 lines
1.4 KiB
PowerShell

# Run as Admin
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "You need to run this script as an Administrator!"
exit
}
# Load Windows Forms assembly for MessageBox
Add-Type -AssemblyName System.Windows.Forms
# Define the restore point description and type
$description = "Bloatynosy NueEx Restore Point"
$restorePointType = 12 # MODIFY_SETTINGS = 12
# Function to create restore point with progress reporting
function Create-RestorePoint {
Write-Host "Starting to create restore point..." -ForegroundColor Yellow
# Simulate progress
for ($i = 0; $i -le 100; $i += 10) {
Write-Progress -Activity "Creating Restore Point" -Status "$i% Complete" -PercentComplete $i
Start-Sleep -Milliseconds 300 # Simulate some work being done
}
# WMI query to create the restore point
$restorePoint = Get-WmiObject -List Win32_SystemRestore | ForEach-Object {
$_.CreateRestorePoint($description, $restorePointType, 100)
}
Write-Host "Restore point created successfully." -ForegroundColor Green
# Show completion message
[System.Windows.Forms.MessageBox]::Show("Restore point has been created successfully!", "Completion", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information)
}
# Execute the restore point creation
Create-RestorePoint