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
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
Solitaire,CandyCrush,Netflix,TikTok,Facebook,Twitter,Instagram,Spotify,
|
||||
Skype,OneNote,OneDrive, Mail, Calendar, Weather,News,Maps,
|
||||
Groove, Movies,TV, Phone, Camera,Feedback,FeedbackHub, GetHelp,
|
||||
Solitaire,CandyCrush,Netflix,TikTok,Facebook,Twitter,Instagram,Spotify,
|
||||
Skype,OneNote,OneDrive,Mail,Calendar,Weather,News,Maps,
|
||||
Groove,Movies,TV,Phone,Camera,Feedback,FeedbackHub,GetHelp,
|
||||
GetStarted,Messaging,Office,Paint3D,Print3D,StickyNotes,Wallet,
|
||||
YourPhone,3DViewer,Alarms,VoiceRecorder,ToDo,Whiteboard,ZuneMusic,
|
||||
ZuneVideo,3DViewer, DevHome, Copilot
|
||||
ZuneVideo,DevHome,Copilot
|
||||
@@ -1,6 +1,5 @@
|
||||
# Run as Admin
|
||||
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
|
||||
{
|
||||
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
|
||||
}
|
||||
@@ -15,7 +14,7 @@ $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
|
||||
@@ -28,10 +27,10 @@ function Create-RestorePoint {
|
||||
}
|
||||
|
||||
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
|
||||
Create-RestorePoint
|
||||
@@ -10,7 +10,8 @@ do {} until (Elevate-Privileges SeTakeOwnershipPrivilege)
|
||||
|
||||
Write-Output "Uninstalling default apps"
|
||||
$apps = @(
|
||||
# default Windows 10 apps
|
||||
# Group by Microsoft and third-party
|
||||
# Microsoft Apps
|
||||
"Microsoft.549981C3F5F10" #Cortana
|
||||
"Microsoft.3DBuilder"
|
||||
"Microsoft.Appconnector"
|
||||
@@ -90,7 +91,7 @@ $apps = @(
|
||||
"A278AB0D.DisneyMagicKingdoms"
|
||||
"A278AB0D.MarchofEmpires"
|
||||
"ActiproSoftwareLLC.562882FEEB491" # next one is for the Code Writer from Actipro Software LLC
|
||||
"CAF9E577.Plex"
|
||||
"CAF9E577.Plex"
|
||||
"ClearChannelRadioDigital.iHeartRadio"
|
||||
"D52A8D61.FarmVille2CountryEscape"
|
||||
"D5EA27B7.Duolingo-LearnLanguagesforFree"
|
||||
@@ -138,8 +139,8 @@ foreach ($app in $apps) {
|
||||
|
||||
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage -AllUsers
|
||||
|
||||
($appxprovisionedpackage).Where( {$_.DisplayName -EQ $app}) |
|
||||
Remove-AppxProvisionedPackage -Online
|
||||
($appxprovisionedpackage).Where( { $_.DisplayName -EQ $app }) |
|
||||
Remove-AppxProvisionedPackage -Online
|
||||
} Write-Host "Clippy has completed the process and removed all possible apps."
|
||||
|
||||
# Prevents Apps from re-installing
|
||||
@@ -169,4 +170,4 @@ Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore" "AutoDow
|
||||
|
||||
# Prevents "Suggested Applications" returning
|
||||
New-FolderForced -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" "DisableWindowsConsumerFeatures" 1
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" "DisableWindowsConsumerFeatures" 1
|
||||
@@ -1,4 +1,13 @@
|
||||
# Function to show a message box
|
||||
#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,
|
||||
@@ -15,4 +24,4 @@ Stop-Process -Name explorer -Force
|
||||
Start-Process explorer
|
||||
|
||||
# Show message box
|
||||
Show-MessageBox -message "Windows Explorer has been restarted successfully." -title "Crapfixer"
|
||||
Show-MessageBox -message "Windows Explorer has been restarted successfully." -title "Crapfixer"
|
||||
@@ -1,3 +1,12 @@
|
||||
#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 must be run as Administrator."
|
||||
Start-Process powershell.exe -Verb RunAs -ArgumentList ("-File `"{0}`"" -f $MyInvocation.MyCommand.Path)
|
||||
exit
|
||||
}
|
||||
|
||||
# Get all installed Windows apps for all users
|
||||
$allApps = Get-AppxPackage -AllUsers
|
||||
|
||||
@@ -16,7 +25,8 @@ foreach ($app in $allApps) {
|
||||
Add-AppxPackage -Register "$($app.InstallLocation)\appxmanifest.xml" -DisableDevelopmentMode -ErrorAction Stop
|
||||
Write-Host "[$currentAppIndex / $totalApps] $($app.Name) reinstalled successfully." -ForegroundColor Green
|
||||
$reinstalledCount++
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
Write-Host "[$currentAppIndex / $totalApps] Error occurred while reinstalling $($app.Name): $_" -ForegroundColor Red
|
||||
}
|
||||
|
||||
@@ -28,4 +38,7 @@ foreach ($app in $allApps) {
|
||||
if ($reinstalledCount -eq $totalApps) {
|
||||
Write-Host "All apps reinstalled successfully." -ForegroundColor Green
|
||||
Write-Host "Flyby11 has reinstalled everything possible." -ForegroundColor Cyan
|
||||
}
|
||||
# Add success percentage reporting
|
||||
$successPercentage = [math]::Round(($reinstalledCount / $totalApps) * 100, 2)
|
||||
Write-Host "Completed with $successPercentage% success rate ($reinstalledCount of $totalApps apps reinstalled)" -ForegroundColor Cyan
|
||||
}
|
||||
@@ -1,3 +1,12 @@
|
||||
#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 must be run as Administrator."
|
||||
Start-Process powershell.exe -Verb RunAs -ArgumentList ("-File `"{0}`"" -f $MyInvocation.MyCommand.Path)
|
||||
exit
|
||||
}
|
||||
|
||||
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\force-mkdir.psm1
|
||||
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\take-own.psm1
|
||||
|
||||
@@ -50,11 +59,11 @@ Write-Output "Restarting explorer"
|
||||
Start-Process "explorer.exe"
|
||||
|
||||
Write-Output "Waiting for explorer to complete loading"
|
||||
Start-Sleep 10
|
||||
Start-Sleep 10 # Consider if this sleep is always necessary or could be shorter/conditional
|
||||
|
||||
Write-Output "Removing additional OneDrive leftovers"
|
||||
foreach ($item in (Get-ChildItem "$env:WinDir\WinSxS\*onedrive*")) {
|
||||
Takeown-Folder $item.FullName
|
||||
Remove-Item -Recurse -Force $item.FullName
|
||||
}
|
||||
Write-Output "Bloatynosy NueEx can confirm the uninstallation of the OneDrive app."
|
||||
Write-Output "Bloatynosy NueEx can confirm the uninstallation of the OneDrive app."
|
||||
Reference in New Issue
Block a user