Local Reinstall Windows -
Start-LocalReinstall // CLI Version public class WindowsResetCLI
static async Task Main(string[] args) var options = ParseArguments(args); var resetService = new WindowsResetService(); Console.WriteLine("⚠️ WARNING: This will reinstall Windows!"); Console.WriteLine($"Keep files: options.KeepPersonalFiles"); Console.WriteLine($"Keep apps: options.KeepInstalledApps"); Console.Write("Continue? (yes/no): "); if (Console.ReadLine()?.ToLower() == "yes") await resetService.ValidateLocalImage(); await resetService.ExecuteReinstall(options);
return $true
private async Task CopyDirectoryAsync(string source, string destination)
// Use Windows.System.UserProfile.UserProfilePersonalizationSettings // or invoke system reset using Process.Start with systemreset.exe string resetArgs = options.KeepPersonalFiles ? "-keepmyfiles" : "-cleanpc"; using (Process process = new Process()) process.StartInfo.FileName = "systemreset.exe"; process.StartInfo.Arguments = resetArgs; process.StartInfo.UseShellExecute = true; process.StartInfo.Verb = "runas"; // Run as administrator process.Start(); await process.WaitForExitAsync(); local reinstall windows
if (options.KeepPersonalFiles) string backupPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "WindowsResetBackup"); Directory.CreateDirectory(backupPath); // Backup user profiles string usersPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); await CopyDirectoryAsync(usersPath, Path.Combine(backupPath, "UserData"));
# Keep files only WindowsReset.exe --keep-files WindowsReset.exe --clean-all Using PowerShell .\LocalWindowsReinstall.ps1 -KeepFiles -KeepApps var resetService = new WindowsResetService()
if ($KeepFiles) Start-Process "systemreset.exe" -ArgumentList "-keepmyfiles" -Wait -NoNewWindow else Start-Process "systemreset.exe" -ArgumentList "-cleanpc" -Wait -NoNewWindow