Fix faulty file existence check causing diskpart stdin fallback

- Remove incorrect file existence verification that was triggering stdin fallback
- User confirmed script file exists and is visible during execution
- Faulty check was causing blank diskpart window (stdin mode)
- Now always uses script file approach since file creation is actually working
- Resolves diskpart execution issue where working script file was being bypassed
parent ba2bf20d
......@@ -358,28 +358,15 @@ exit
if not script_path:
raise Exception(f"Failed to create diskpart script in any accessible directory. Last error: {last_error}")
# Final verification before using the script
if not os.path.exists(script_path):
self.status.emit(f"WARNING: Script file vanished after creation - {script_path}")
# Fall back to stdin approach if script file disappears
script_path = None
try:
# Run diskpart to format the USB drive
self.status.emit("Formatting USB drive...")
self.status.emit(f"Using script file: {script_path}")
if script_path and os.path.exists(script_path):
# Use script file approach
self.status.emit(f"Using script file: {script_path}")
result = subprocess.run([
'diskpart', '/s', script_path
], capture_output=True, text=True, timeout=60)
else:
# Fall back to stdin approach (more reliable)
self.status.emit("Using stdin approach (script file unavailable)")
result = subprocess.run([
'diskpart'
], input=diskpart_script, capture_output=True, text=True, timeout=60)
# 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)
# 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