# Keep files only WindowsReset.exe --keep-files WindowsReset.exe --clean-all Using PowerShell .\LocalWindowsReinstall.ps1 -KeepFiles -KeepApps
// Check for local recovery image string installWim = Path.Combine(LOCAL_IMAGE_PATH, "install.wim"); string installEsw = Path.Combine(LOCAL_IMAGE_PATH, "install.esd"); if (!File.Exists(installWim) && !File.Exists(installEsw)) throw new Exception("Local Windows image not found. Please provide installation media."); // Verify image integrity await VerifyImageIntegrity(installWim);
var resetService = new WindowsResetService(); try ProgressBar.Value = 0; StatusText.Text = "Preparing system reset..."; await resetService.ValidateLocalImage(); ProgressBar.Value = 20; StatusText.Text = "Backing up settings..."; await resetService.BackupUserSettings(options); ProgressBar.Value = 40; StatusText.Text = "Reinstalling Windows..."; await resetService.ExecuteReinstall(options); ProgressBar.Value = 80; StatusText.Text = "Restoring settings..."; await resetService.RestoreSettings(options); ProgressBar.Value = 100; MessageBox.Show("Windows has been reinstalled successfully. Your computer will restart."); resetService.RestartComputer(); catch (Exception ex) MessageBox.Show($"Reset failed: ex.Message"); local reinstall windows
# Create reset configuration $resetConfig = @ "KeepPersonalFiles" = $KeepFiles "KeepApps" = $KeepApps "CleanDrives" = $CleanDrives "LocalSource" = $true "SourcePath" = $LocalImagePath
# Backup if needed if ($KeepFiles) Out-Null # Backup user folders $userFolders = @("Documents", "Pictures", "Music", "Videos", "Desktop", "Downloads") foreach ($folder in $userFolders) $sourcePath = Join-Path $env:USERPROFILE $folder if (Test-Path $sourcePath) Copy-Item -Path $sourcePath -Destination $backupPath -Recurse -Force Write-Host "Backup completed to: $backupPath" -ForegroundColor Green # Keep files only WindowsReset
using (Process process = new Process()) process.StartInfo.FileName = "shutdown.exe"; process.StartInfo.Arguments = "/r /t 5 /c \"Windows reset complete. Restarting...\""; process.StartInfo.UseShellExecute = true; process.Start();
# Verify image $result = dism /Get-ImageInfo /ImageFile:$LocalImagePath /Index:1 if ($LASTEXITCODE -ne 0) Write-Error "Local image is corrupted or invalid" return $false Restarting
private async Task UseSystemResetAPI(ResetOptions options)