mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-02-04 06:50:09 +00:00
Bring-Back-#3710 (#3809)
* Update WPFTweaksRestorePoint * Update tweaks.json * Fix PowerShell script syntax in tweaks.json * Update tweaks.json
This commit is contained in:
@@ -1932,46 +1932,23 @@
|
||||
"panel": "1",
|
||||
"Checked": "False",
|
||||
"Order": "a001_",
|
||||
"registry": [
|
||||
{
|
||||
"Path": "HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SystemRestore",
|
||||
"Name": "SystemRestorePointCreationFrequency",
|
||||
"Type": "DWord",
|
||||
"Value": "0",
|
||||
"OriginalValue": "1440"
|
||||
}
|
||||
],
|
||||
"InvokeScript": [
|
||||
"
|
||||
# Check if System Restore is enabled for the main drive
|
||||
try {
|
||||
# Try getting restore points to check if System Restore is enabled
|
||||
Enable-ComputerRestore -Drive \"$env:SystemDrive\"
|
||||
} catch {
|
||||
Write-Host \"An error occurred while enabling System Restore: $_\"
|
||||
}
|
||||
|
||||
# Check if the SystemRestorePointCreationFrequency value exists
|
||||
$exists = Get-ItemProperty -path \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SystemRestore\" -Name \"SystemRestorePointCreationFrequency\" -ErrorAction SilentlyContinue
|
||||
if($null -eq $exists) {
|
||||
write-host 'Changing system to allow multiple restore points per day'
|
||||
Set-ItemProperty -Path \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SystemRestore\" -Name \"SystemRestorePointCreationFrequency\" -Value \"0\" -Type DWord -Force -ErrorAction Stop | Out-Null
|
||||
}
|
||||
|
||||
# Attempt to load the required module for Get-ComputerRestorePoint
|
||||
try {
|
||||
Import-Module Microsoft.PowerShell.Management -ErrorAction Stop
|
||||
} catch {
|
||||
Write-Host \"Failed to load the Microsoft.PowerShell.Management module: $_\"
|
||||
return
|
||||
}
|
||||
|
||||
# Get all the restore points for the current day
|
||||
try {
|
||||
$existingRestorePoints = Get-ComputerRestorePoint | Where-Object { $_.CreationTime.Date -eq (Get-Date).Date }
|
||||
} catch {
|
||||
Write-Host \"Failed to retrieve restore points: $_\"
|
||||
return
|
||||
}
|
||||
|
||||
# Check if there is already a restore point created today
|
||||
if ($existingRestorePoints.Count -eq 0) {
|
||||
$description = \"System Restore Point created by WinUtil\"
|
||||
|
||||
Checkpoint-Computer -Description $description -RestorePointType \"MODIFY_SETTINGS\"
|
||||
Write-Host -ForegroundColor Green \"System Restore Point Created Successfully\"
|
||||
}
|
||||
if (-not (Get-ComputerRestorePoint)) {
|
||||
Enable-ComputerRestore -Drive $Env:SystemDrive
|
||||
}
|
||||
|
||||
Checkpoint-Computer -Description \"System Restore Point created by WinUtil\" -RestorePointType MODIFY_SETTINGS
|
||||
Write-Host \"System Restore Point Created Successfully\" -ForegroundColor Green
|
||||
"
|
||||
],
|
||||
"link": "https://winutil.christitus.com/dev/tweaks/essential-tweaks/restorepoint"
|
||||
|
||||
Reference in New Issue
Block a user