Winbootmate Full ((new)) Instant
self.log(f"\n--- Creating bootable USB on {usb_drive} from {iso_path} ---") self.log("This will FORMAT the USB drive. Continue?") if not messagebox.askyesno("Warning", f"All data on {usb_drive} will be erased. Continue?"): return
self.log("Extracting ISO to USB (this may take a while)...") # Mount ISO mount_result = subprocess.run(f'powershell Mount-DiskImage -ImagePath "{iso_path}" -PassThru', capture_output=True, text=True) if mount_result.returncode != 0: self.log("Failed to mount ISO. Try using Rufus or Ventoy.") return # Get mounted drive letter mount_letter = None for line in mount_result.stdout.splitlines(): if ":" in line and "\\" in line: # crude extraction parts = line.split() for p in parts: if len(p) == 2 and p[1] == ':': mount_letter = p break if not mount_letter: self.log("Could not find mounted ISO drive.") return winbootmate full
def log(self, msg): self.output.insert(tk.END, msg + "\n") self.output.see(tk.END) self.root.update() Try using Rufus or Ventoy
# Copy files try: subprocess.run(f'xcopy {mount_letter}\\* {usb_drive}\\ /E /H /Y', shell=True, check=True) self.log("Files copied. Making bootable...") # Make bootable boot_sect_path = os.path.join(os.environ['WINDIR'], 'System32', 'bootsect.exe') if os.path.exists(boot_sect_path): subprocess.run(f'{boot_sect_path} /nt60 {usb_drive}', shell=True) self.log(f"✓ Bootable USB created on {usb_drive}") except Exception as e: self.log(f"✗ Copy failed: {e}") finally: subprocess.run(f'powershell Dismount-DiskImage -ImagePath "{iso_path}"', shell=True) "Fix MBR") self.run_admin_cmd("bootrec /fixboot"
def fix_boot_errors(self): self.log("\n--- Attempting common boot fixes ---") self.run_admin_cmd("bootrec /fixmbr", "Fix MBR") self.run_admin_cmd("bootrec /fixboot", "Fix boot sector") self.run_admin_cmd("bootrec /scanos", "Scan for OS") self.run_admin_cmd("bootrec /rebuildbcd", "Rebuild BCD") self.log("Reboot to see if issues are resolved.")
# Use diskpart + bootsect (common method) with tempfile.NamedTemporaryFile(mode='w', suffix='.txt', delete=False) as dp_script: dp_script.write(f"select volume {usb_drive[0]}\nclean\ncreate partition primary\nactive\nformat fs=ntfs quick\nassign letter={usb_drive[0]}\nexit\n") dp_script_path = dp_script.name
