Enhance 7-zip detection on Windows

- Try 7z from PATH first
- Fallback to default installation directories:
  - C:\Program Files\7-Zip\7z.exe
  - C:\Program Files (x86)\7-Zip\7z.exe
- Better error handling for extraction failures
- Improves compatibility with standard 7-zip installations on Windows
parent ab3b9e0c
......@@ -105,10 +105,36 @@ class WorkerThread(QThread):
def extract_iso_windows(self, iso_file, extract_dir):
# Use 7-zip to extract ISO on Windows
# Try 7z from PATH first
seven_zip_cmd = '7z'
try:
subprocess.run(['7z', 'x', f'-o{extract_dir}', iso_file], check=True)
subprocess.run([seven_zip_cmd, 'x', f'-o{extract_dir}', iso_file], check=True)
return
except FileNotFoundError:
raise Exception("7-zip not found. Please install 7-zip for Windows.")
# Try default 7-zip installation directory
default_7z_path = r"C:\Program Files\7-Zip\7z.exe"
if os.path.exists(default_7z_path):
seven_zip_cmd = default_7z_path
try:
subprocess.run([seven_zip_cmd, 'x', f'-o{extract_dir}', iso_file], check=True)
return
except subprocess.CalledProcessError:
raise Exception("7-zip extraction failed.")
# Also try Program Files (x86) for 32-bit systems
default_7z_path_x86 = r"C:\Program Files (x86)\7-Zip\7z.exe"
if os.path.exists(default_7z_path_x86):
seven_zip_cmd = default_7z_path_x86
try:
subprocess.run([seven_zip_cmd, 'x', f'-o{extract_dir}', iso_file], check=True)
return
except subprocess.CalledProcessError:
raise Exception("7-zip extraction failed.")
raise Exception("7-zip not found. Please install 7-zip for Windows or add it to PATH.")
except subprocess.CalledProcessError:
raise Exception("7-zip extraction failed.")
def modify_root_password(self, iso_dir):
# Find and modify preseed file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment