tk.Button(btn_frame, text="4. Create Bootable USB", command=self.create_bootable_usb, width=20).grid(row=1, column=0, padx=5, pady=5) tk.Button(btn_frame, text="5. Fix Boot Errors", command=self.fix_boot_errors, width=20).grid(row=1, column=1, padx=5, pady=5) tk.Button(btn_frame, text="6. Rebuild BCD", command=self.rebuild_bcd, width=20).grid(row=1, column=2, padx=5, pady=5)
def create_bootable_usb(self): iso_path = filedialog.askopenfilename(title="Select Windows ISO", filetypes=[("ISO files", "*.iso")]) if not iso_path: return # Get USB drive letter drives = [] for d in ['D:', 'E:', 'F:', 'G:', 'H:', 'I:']: if os.path.exists(d): drives.append(d) if not drives: self.log("No removable drives found.") return
def run_admin_cmd(self, command, description=""): """Run a shell command that may need admin rights.""" try: self.log(f">>> {description or command}") result = subprocess.run(command, shell=True, capture_output=True, text=True) if result.returncode == 0: self.log("✓ Success") self.log(result.stdout) else: self.log("✗ Failed") self.log(result.stderr) return result except Exception as e: self.log(f"Error: {e}") return None winbootmate full
def log(self, msg): self.output.insert(tk.END, msg + "\n") self.output.see(tk.END) self.root.update()
class WinBootMate: def (self, root): self.root = root self.root.title("WinBootMate - Boot Assistant") self.root.geometry("700x550") self.root.resizable(True, True) Rebuild BCD", command=self
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
def backup_bcd(self): backup_path = filedialog.asksaveasfilename(defaultextension=".bcd", filetypes=[("BCD files", "*.bcd")]) if backup_path: self.log(f"\n--- Backing up BCD to {backup_path} ---") # BCD store location (UEFI typically) bcd_path = r"C:\Boot\BCD" if not os.path.exists(bcd_path): bcd_path = r"C:\EFI\Microsoft\Boot\BCD" try: shutil.copy2(bcd_path, backup_path) self.log(f"✓ Backup saved to {backup_path}") except Exception as e: self.log(f"✗ Backup failed: {e}") {description or command}") result = subprocess.run(command
# Title title = tk.Label(root, text="WinBootMate", font=("Segoe UI", 16, "bold")) title.pack(pady=10)