From 8495d62a06caddc6b3eec9ca66151d641c0fc518 Mon Sep 17 00:00:00 2001
From: 2Shirt <2xShirt@gmail.com>
Date: Sat, 13 Dec 2025 16:58:47 -0800
Subject: [PATCH] Add unattend.xml sections
---
config/unattend.xml | 83 ++++++++++++++++++++++++++++++++++++++++
win_installer/src/app.rs | 30 ++++++++++++++-
win_installer/src/wim.rs | 6 +++
3 files changed, 118 insertions(+), 1 deletion(-)
create mode 100755 config/unattend.xml
diff --git a/config/unattend.xml b/config/unattend.xml
new file mode 100755
index 0000000..fe7ea54
--- /dev/null
+++ b/config/unattend.xml
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ reg add HKLM\SYSTEM\Setup\LabConfig /v BypassTPMCheck /t REG_DWORD /d 1 /f
+
+
+ 2
+ reg add HKLM\SYSTEM\Setup\LabConfig /v BypassSecureBootCheck /t REG_DWORD /d 1 /f
+
+
+ 3
+ reg add HKLM\SYSTEM\Setup\LabConfig /v BypassRAMCheck /t REG_DWORD /d 1 /f
+
+
+
+
+
+
+
+
+ 1
+ reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OOBE /v BypassNRO /t REG_DWORD /d 1 /f
+
+
+
+
+
+
+
+ 3
+
+
+
+
+ NEWUSERNAME
+ NEWUSERNAME
+ Administrators;Power Users
+
+ UABhAHMAcwB3AG8AcgBkAA==
+ false
+
+
+
+
+
+
+ 1
+ net user "NEWUSERNAME" /expires:never
+
+
+ 2
+ net user "NEWUSERNAME" /passwordchg:yes
+
+
+ 3
+ net user "NEWUSERNAME" /passwordreq:no
+
+
+
+
+ 00000409
+ en-US
+ en-US
+ en-US
+
+
+
+ true
+
+
+ 1
+
+
+
diff --git a/win_installer/src/app.rs b/win_installer/src/app.rs
index a430e50..c6d5773 100644
--- a/win_installer/src/app.rs
+++ b/win_installer/src/app.rs
@@ -38,6 +38,8 @@ use core::{
};
use std::{
env,
+ fs::{File, create_dir_all},
+ io::Write,
iter::zip,
path::PathBuf,
sync::{Arc, Mutex},
@@ -51,11 +53,12 @@ use ratatui::{
style::Color,
};
use tokio::sync::mpsc;
-use tracing::{debug, info};
+use tracing::{debug, error, info};
use crate::{
components::{set_username::InputUsername, wim_scan::WimScan},
state::{ScanType, State},
+ wim::gen_unattend_xml,
};
pub struct App {
@@ -220,6 +223,8 @@ impl App {
popup::Type::Info,
String::from("Updating boot configuration"),
))?;
+ let wim_sources = self.state.wim_sources.lock().unwrap();
+ let wim_file = wim_sources.get_file(self.state.wim_file_index.unwrap());
// Get System32 path
let system32 = get_system32_path(&self.action_tx);
@@ -270,6 +275,29 @@ impl App {
)))?;
}
}
+
+ // Add unattend.xml (if applicable)
+ if let Some(username) = &self.state.username
+ && !wim_file.is_backup
+ {
+ let unattend_xml_str = gen_unattend_xml(username);
+ let panther_path = format!("{letter_os}:\\Windows\\Panther");
+ if create_dir_all(PathBuf::from(&panther_path)).is_ok() {
+ if let Ok(mut unattend_xml) =
+ File::create(format!("{panther_path}\\unattend.xml"))
+ {
+ if unattend_xml.write_all(unattend_xml_str.as_bytes()).is_ok() {
+ info!("Created unattend.xml with username set to: {username}");
+ } else {
+ error!("Failed to write to unattend.xml");
+ }
+ } else {
+ error!("Failed to create unattend.xml");
+ }
+ } else {
+ error!("Failed to create Panther dir");
+ }
+ }
}
}
Mode::ScanDisks => {
diff --git a/win_installer/src/wim.rs b/win_installer/src/wim.rs
index bdb5bca..433d0aa 100644
--- a/win_installer/src/wim.rs
+++ b/win_installer/src/wim.rs
@@ -30,6 +30,8 @@ use xml::reader::{EventReader, XmlEvent};
use core::system::disk::bytes_to_string;
+const UNATTEND_XML: &str = include_str!("../../config/unattend.xml");
+
static WIMINFO_EXE: LazyLock = LazyLock::new(|| {
let program_files =
PathBuf::from(env::var("PROGRAMFILES").expect("Failed to resolve %PROGRAMFILES%"));
@@ -229,6 +231,10 @@ impl WimSources {
}
}
+pub fn gen_unattend_xml(username: &str) -> String {
+ UNATTEND_XML.replace("NEWUSERNAME", username)
+}
+
fn get_wim_xml(wim_file: &str) -> std::io::Result {
let tmp_file = NamedTempFile::new()?;
let _ = Command::new(&*WIMINFO_EXE)