@@ -77,116 +77,117 @@ bool StartnetConfigurator::createMinimalStartnet(const std::string &mountDir, st
7777 snOut.close ();
7878
7979 // Create persistent mount script in X:\ (will be in WIM root)
80- std::string mountScript = mountDir + " \\ mount_partitions.cmd" ;
81- std::string mountContent = " @echo off\r\n "
82- " rem Persistent partition mounting for Windows Setup\r\n "
83- " echo.\r\n "
84- " echo ====================================================\r\n "
85- " echo Preparing Windows Setup environment...\r\n "
86- " echo ====================================================\r\n "
87- " echo.\r\n "
88- " \r\n "
89- " rem Rescan disks\r\n "
90- " echo [1/4] Rescanning disks...\r\n "
91- " echo rescan > X:\\ rescan2.txt\r\n "
92- " diskpart /s X:\\ rescan2.txt\r\n "
93- " if errorlevel 1 (\r\n "
94- " echo WARNING: Disk rescan failed\r\n "
95- " )\r\n "
96- " del X:\\ rescan2.txt 2>nul\r\n "
97- " \r\n "
98- " rem Mount all partitions with verbose output\r\n "
99- " echo [2/4] Mounting all partitions on disk 0...\r\n "
100- " echo list partition > X:\\ list_part.txt\r\n "
101- " diskpart /s X:\\ list_part.txt > X:\\ part_list.txt 2>&1\r\n "
102- " for /L %%p in (1,1,6) do (\r\n "
103- " echo Mounting partition %%p...\r\n "
104- " echo select disk 0 > X:\\ mount%%p.txt\r\n "
105- " echo select partition %%p >> X:\\ mount%%p.txt\r\n "
106- " echo assign >> X:\\ mount%%p.txt\r\n "
107- " diskpart /s X:\\ mount%%p.txt > X:\\ mount_out%%p.txt 2>&1\r\n "
108- " findstr /C:\" DiskPart successfully assigned\" X:\\ mount_out%%p.txt > nul 2>&1\r\n "
109- " if errorlevel 1 (\r\n "
110- " findstr /C:\" No drive letter or mount point\" X:\\ mount_out%%p.txt > nul 2>&1\r\n "
111- " if errorlevel 1 (\r\n "
112- " echo WARNING: Failed to mount partition %%p (may not exist or already mounted)\r\n "
113- " ) else (\r\n "
114- " echo SUCCESS: Partition %%p already has a drive letter\r\n "
115- " )\r\n "
116- " ) else (\r\n "
117- " echo SUCCESS: Partition %%p mounted\r\n "
118- " )\r\n "
119- " del X:\\ mount%%p.txt 2>nul\r\n "
120- " del X:\\ mount_out%%p.txt 2>nul\r\n "
121- " )\r\n "
122- " del X:\\ list_part.txt 2>nul\r\n "
123- " del X:\\ part_list.txt 2>nul\r\n "
124- " \r\n "
125- " rem Wait for partitions to stabilize\r\n "
126- " echo [3/4] Waiting for partitions to stabilize...\r\n "
127- " ping 127.0.0.1 -n 5 > nul\r\n "
128- " \r\n "
129- " rem List all available drives for debugging\r\n "
130- " echo [4/4] Searching for Windows installation files...\r\n "
131- " echo Available drives after mounting:\r\n "
132- " for %%d in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (\r\n "
133- " if exist %%d:\\ echo %%d:\r\n "
134- " )\r\n "
135- " echo.\r\n "
136- " \r\n "
137- " rem Additional wait for critical partitions to be ready\r\n "
138- " echo Waiting for critical partitions to be fully accessible...\r\n "
139- " ping 127.0.0.1 -n 3 > nul\r\n "
140- " \r\n "
141- " rem Find partition with install.esd/wim and setup.exe (exclude only X: WinPE)\r\n "
142- " set INSTALL_DRIVE=\r\n "
143- " for %%d in (C D E F G H I J K L M N O P Q R S T U V W Y Z) do (\r\n "
144- " rem Skip X: drive (WinPE)\r\n "
145- " if not \" %%d\" ==\" X\" (\r\n "
146- " if exist %%d:\\ sources\\ install.esd if exist %%d:\\ setup.exe (\r\n "
147- " set INSTALL_DRIVE=%%d\r\n "
148- " echo Found install.esd on %%d:\r\n "
149- " )\r\n "
150- " if exist %%d:\\ sources\\ install.wim if exist %%d:\\ setup.exe (\r\n "
151- " set INSTALL_DRIVE=%%d\r\n "
152- " echo Found install.wim on %%d:\r\n "
153- " )\r\n "
154- " )\r\n "
155- " )\r\n "
156- " \r\n "
157- " rem If installation partition found, launch Setup from there\r\n "
158- " if defined INSTALL_DRIVE (\r\n "
159- " echo.\r\n "
160- " echo ====================================================\r\n "
161- " echo SUCCESS: Found Windows installation on %INSTALL_DRIVE%:\r\n "
162- " echo ====================================================\r\n "
163- " echo.\r\n "
164- " echo Launching Windows Setup from %INSTALL_DRIVE%:...\r\n "
165- " \r\n "
166- " rem Kill any Setup running from X: and launch from install drive\r\n "
167- " taskkill /IM setup.exe /F > nul 2>&1\r\n "
168- " ping 127.0.0.1 -n 2 > nul\r\n "
169- " \r\n "
170- " rem Launch Setup from the partition with install files\r\n "
171- " cd /d %INSTALL_DRIVE%:\\\r\n "
172- " start setup.exe\r\n "
173- " \r\n "
174- " echo Setup launched successfully from %INSTALL_DRIVE%:\r\n "
175- " echo.\r\n "
176- " ) else (\r\n "
177- " echo.\r\n "
178- " echo ====================================================\r\n "
179- " echo WARNING: No Windows installation files found\r\n "
180- " echo ====================================================\r\n "
181- " echo.\r\n "
182- " echo Searched for:\r\n "
183- " echo - sources\\ install.esd or sources\\ install.wim\r\n "
184- " echo - setup.exe\r\n "
185- " echo.\r\n "
186- " echo Please mount partitions manually and run setup.exe\r\n "
187- " echo.\r\n "
188- " pause\r\n "
189- " )\r\n " ;
80+ std::string mountScript = mountDir + " \\ mount_partitions.cmd" ;
81+ std::string mountContent =
82+ " @echo off\r\n "
83+ " rem Persistent partition mounting for Windows Setup\r\n "
84+ " echo.\r\n "
85+ " echo ====================================================\r\n "
86+ " echo Preparing Windows Setup environment...\r\n "
87+ " echo ====================================================\r\n "
88+ " echo.\r\n "
89+ " \r\n "
90+ " rem Rescan disks\r\n "
91+ " echo [1/4] Rescanning disks...\r\n "
92+ " echo rescan > X:\\ rescan2.txt\r\n "
93+ " diskpart /s X:\\ rescan2.txt\r\n "
94+ " if errorlevel 1 (\r\n "
95+ " echo WARNING: Disk rescan failed\r\n "
96+ " )\r\n "
97+ " del X:\\ rescan2.txt 2>nul\r\n "
98+ " \r\n "
99+ " rem Mount all partitions with verbose output\r\n "
100+ " echo [2/4] Mounting all partitions on disk 0...\r\n "
101+ " echo list partition > X:\\ list_part.txt\r\n "
102+ " diskpart /s X:\\ list_part.txt > X:\\ part_list.txt 2>&1\r\n "
103+ " for /L %%p in (1,1,6) do (\r\n "
104+ " echo Mounting partition %%p...\r\n "
105+ " echo select disk 0 > X:\\ mount%%p.txt\r\n "
106+ " echo select partition %%p >> X:\\ mount%%p.txt\r\n "
107+ " echo assign >> X:\\ mount%%p.txt\r\n "
108+ " diskpart /s X:\\ mount%%p.txt > X:\\ mount_out%%p.txt 2>&1\r\n "
109+ " findstr /C:\" DiskPart successfully assigned\" X:\\ mount_out%%p.txt > nul 2>&1\r\n "
110+ " if errorlevel 1 (\r\n "
111+ " findstr /C:\" No drive letter or mount point\" X:\\ mount_out%%p.txt > nul 2>&1\r\n "
112+ " if errorlevel 1 (\r\n "
113+ " echo WARNING: Failed to mount partition %%p (may not exist or already mounted)\r\n "
114+ " ) else (\r\n "
115+ " echo SUCCESS: Partition %%p already has a drive letter\r\n "
116+ " )\r\n "
117+ " ) else (\r\n "
118+ " echo SUCCESS: Partition %%p mounted\r\n "
119+ " )\r\n "
120+ " del X:\\ mount%%p.txt 2>nul\r\n "
121+ " del X:\\ mount_out%%p.txt 2>nul\r\n "
122+ " )\r\n "
123+ " del X:\\ list_part.txt 2>nul\r\n "
124+ " del X:\\ part_list.txt 2>nul\r\n "
125+ " \r\n "
126+ " rem Wait for partitions to stabilize\r\n "
127+ " echo [3/4] Waiting for partitions to stabilize...\r\n "
128+ " ping 127.0.0.1 -n 5 > nul\r\n "
129+ " \r\n "
130+ " rem List all available drives for debugging\r\n "
131+ " echo [4/4] Searching for Windows installation files...\r\n "
132+ " echo Available drives after mounting:\r\n "
133+ " for %%d in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (\r\n "
134+ " if exist %%d:\\ echo %%d:\r\n "
135+ " )\r\n "
136+ " echo.\r\n "
137+ " \r\n "
138+ " rem Additional wait for critical partitions to be ready\r\n "
139+ " echo Waiting for critical partitions to be fully accessible...\r\n "
140+ " ping 127.0.0.1 -n 3 > nul\r\n "
141+ " \r\n "
142+ " rem Find partition with install.esd/wim and setup.exe (exclude only X: WinPE)\r\n "
143+ " set INSTALL_DRIVE=\r\n "
144+ " for %%d in (C D E F G H I J K L M N O P Q R S T U V W Y Z) do (\r\n "
145+ " rem Skip X: drive (WinPE)\r\n "
146+ " if not \" %%d\" ==\" X\" (\r\n "
147+ " if exist %%d:\\ sources\\ install.esd if exist %%d:\\ setup.exe (\r\n "
148+ " set INSTALL_DRIVE=%%d\r\n "
149+ " echo Found install.esd on %%d:\r\n "
150+ " )\r\n "
151+ " if exist %%d:\\ sources\\ install.wim if exist %%d:\\ setup.exe (\r\n "
152+ " set INSTALL_DRIVE=%%d\r\n "
153+ " echo Found install.wim on %%d:\r\n "
154+ " )\r\n "
155+ " )\r\n "
156+ " )\r\n "
157+ " \r\n "
158+ " rem If installation partition found, launch Setup from there\r\n "
159+ " if defined INSTALL_DRIVE (\r\n "
160+ " echo.\r\n "
161+ " echo ====================================================\r\n "
162+ " echo SUCCESS: Found Windows installation on %INSTALL_DRIVE%:\r\n "
163+ " echo ====================================================\r\n "
164+ " echo.\r\n "
165+ " echo Launching Windows Setup from %INSTALL_DRIVE%:...\r\n "
166+ " \r\n "
167+ " rem Kill any Setup running from X: and launch from install drive\r\n "
168+ " taskkill /IM setup.exe /F > nul 2>&1\r\n "
169+ " ping 127.0.0.1 -n 2 > nul\r\n "
170+ " \r\n "
171+ " rem Launch Setup from the partition with install files\r\n "
172+ " cd /d %INSTALL_DRIVE%:\\\r\n "
173+ " start setup.exe\r\n "
174+ " \r\n "
175+ " echo Setup launched successfully from %INSTALL_DRIVE%:\r\n "
176+ " echo.\r\n "
177+ " ) else (\r\n "
178+ " echo.\r\n "
179+ " echo ====================================================\r\n "
180+ " echo WARNING: No Windows installation files found\r\n "
181+ " echo ====================================================\r\n "
182+ " echo.\r\n "
183+ " echo Searched for:\r\n "
184+ " echo - sources\\ install.esd or sources\\ install.wim\r\n "
185+ " echo - setup.exe\r\n "
186+ " echo.\r\n "
187+ " echo Please mount partitions manually and run setup.exe\r\n "
188+ " echo.\r\n "
189+ " pause\r\n "
190+ " )\r\n " ;
190191
191192 std::ofstream msOut (mountScript, std::ios::out | std::ios::binary | std::ios::trunc);
192193 if (!msOut) {
0 commit comments