Fix diskpart script encoding for Windows compatibility

- Use cp1252 (Windows ANSI) encoding instead of UTF-8 for diskpart script
- Diskpart expects ANSI encoding and may not read UTF-8 files correctly
- Should resolve issue where diskpart window remains blank
- File creation and reading now use consistent Windows-compatible encoding
parent f2fb7fbb
......@@ -328,14 +328,14 @@ exit
candidate_path = os.path.join(temp_dir, script_filename)
self.status.emit(f"Directory {i+1}: Trying to create script at {candidate_path}")
# Try to write script file with explicit encoding
with open(candidate_path, 'w', encoding='utf-8') as script_file:
# Try to write script file with Windows ANSI encoding (diskpart expects this)
with open(candidate_path, 'w', encoding='cp1252') as script_file:
script_file.write(diskpart_script)
# Verify file exists and is readable
if os.path.exists(candidate_path) and os.path.isfile(candidate_path):
# Verify we can read the file back
with open(candidate_path, 'r', encoding='utf-8') as verify_file:
with open(candidate_path, 'r', encoding='cp1252') as verify_file:
content = verify_file.read()
if content.strip(): # File has content
script_path = candidate_path
......
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