mirror of
https://github.com/Raphire/Win11Debloat.git
synced 2025-11-17 11:06:18 +00:00
Add check to see if System Restore is enabled, with option to enable it (#235)
Co-authored-by: Lucas <100943586+lucas-timeworkstudio@users.noreply.github.com>
This commit is contained in:
@@ -743,7 +743,26 @@ function GetUserName {
|
|||||||
|
|
||||||
|
|
||||||
function CreateSystemRestorePoint {
|
function CreateSystemRestorePoint {
|
||||||
Write-Output "> Creating system restore point..."
|
Write-Output "> Attempting to create a system restore point..."
|
||||||
|
|
||||||
|
$SysRestore = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name "RPSessionInterval"
|
||||||
|
|
||||||
|
if ($SysRestore.RPSessionInterval -eq 0) {
|
||||||
|
if (-not $Silent) {
|
||||||
|
if ($( Read-Host -Prompt "System restore is disabled, would you like to enable it and create a restore point? (y/n)") -eq 'y') {
|
||||||
|
try {
|
||||||
|
Enable-ComputerRestore -Drive "$env:SystemDrive"
|
||||||
|
} catch {
|
||||||
|
Write-Host "Error: Failed to enable System Restore: $_" -ForegroundColor Red
|
||||||
|
Write-Output ""
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Output ""
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Find existing restore points that are less than 24 hours old
|
# Find existing restore points that are less than 24 hours old
|
||||||
try {
|
try {
|
||||||
@@ -760,10 +779,8 @@ function CreateSystemRestorePoint {
|
|||||||
Write-Output "System restore point created successfully"
|
Write-Output "System restore point created successfully"
|
||||||
} catch {
|
} catch {
|
||||||
Write-Host "Error: Unable to create restore point: $_" -ForegroundColor Red
|
Write-Host "Error: Unable to create restore point: $_" -ForegroundColor Red
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Write-Host "A recent restore point already exists, no new restore point was created." -ForegroundColor Yellow
|
Write-Host "A recent restore point already exists, no new restore point was created." -ForegroundColor Yellow
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -777,11 +794,7 @@ function DisplayCustomModeOptions {
|
|||||||
|
|
||||||
PrintHeader 'Custom Mode'
|
PrintHeader 'Custom Mode'
|
||||||
|
|
||||||
if ($( Read-Host -Prompt "Do you wish to create a system restore point? (y/n)" ) -eq 'y') {
|
AddParameter 'CreateRestorePoint' 'Create a system restore point'
|
||||||
AddParameter 'CreateRestorePoint' 'Create a system restore point'
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Output ""
|
|
||||||
|
|
||||||
# Show options for removing apps, only continue on valid input
|
# Show options for removing apps, only continue on valid input
|
||||||
Do {
|
Do {
|
||||||
|
|||||||
Reference in New Issue
Block a user