Add comprehensive diskpart debugging to identify script execution issues

- Show script content and file size in debug output
- Display exact diskpart command being executed
- Capture and display diskpart stdout and stderr
- Show diskpart exit code for better error analysis
- Use Windows ANSI (cp1252) encoding for better diskpart compatibility
- Should reveal why diskpart window remains blank and help identify the root cause
parent 115966c3
......@@ -363,10 +363,34 @@ exit
self.status.emit("Formatting USB drive...")
self.status.emit(f"Using script file: {script_path}")
# Always try script file approach first since user confirms file exists
result = subprocess.run([
'diskpart', '/s', script_path
], capture_output=True, text=True, timeout=60)
# Add debugging - show script content and file info
try:
with open(script_path, 'r', encoding='cp1252') as debug_file:
script_content = debug_file.read()
self.status.emit(f"Script content ({len(script_content)} chars):")
self.status.emit(script_content)
except Exception as e:
self.status.emit(f"Failed to read script for debugging: {e}")
# Show full command being executed
diskpart_cmd = ['diskpart', '/s', script_path]
self.status.emit(f"Executing: {' '.join(diskpart_cmd)}")
# Try script file approach
result = subprocess.run(
diskpart_cmd,
capture_output=True,
text=True,
timeout=60,
shell=False # Ensure we're not using shell
)
# Show diskpart output for debugging
self.status.emit(f"Diskpart exit code: {result.returncode}")
if result.stdout:
self.status.emit(f"Diskpart stdout: {result.stdout}")
if result.stderr:
self.status.emit(f"Diskpart stderr: {result.stderr}")
# Clean up diskpart script
try:
......
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