Skip to content

Commit c05b1e7

Browse files
committed
20240126
1 parent 9554643 commit c05b1e7

File tree

8 files changed

+372
-78
lines changed

8 files changed

+372
-78
lines changed

W10MUI/Updates/W10UI.cmd

+100-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@setlocal DisableDelayedExpansion
2-
@set uiv=v10.38
2+
@set uiv=v10.39
33
@echo off
44
:: enable debug mode, you must also set target and repo (if updates are not beside the script)
55
set _Debug=0
@@ -20,7 +20,7 @@ set "DismRoot=dism.exe"
2020
:: enable .NET 3.5 feature
2121
set Net35=1
2222

23-
:: optional, specify custom "folder" path for microsoft-windows-netfx3-ondemand-package.cab
23+
:: optional, custom "folder" path for microsoft-windows-netfx3-ondemand-package.cab
2424
set "Net35Source="
2525

2626
:: Cleanup OS images to "compress" superseded components (might take long time to complete)
@@ -56,6 +56,18 @@ set AutoStart=0
5656
:: detect and use wimlib-imagex.exe for exporting wim files instead dism.exe
5757
set UseWimlib=0
5858

59+
:: ### Options for wim or distribution target only ###
60+
61+
:: add drivers to install.wim and boot.wim / winre.wim
62+
set AddDrivers=0
63+
64+
:: custom folder path for drivers - default is "Drivers" folder next to the script
65+
:: the folder must contain subfolder for each drivers target:
66+
:: ALL / drivers will be added to all wim files
67+
:: OS / drivers will be added to install.wim only
68+
:: WinPE / drivers will be added to boot.wim / winre.wim only
69+
set "Drv_Source=\Drivers"
70+
5971
:: ### Options for distribution target only ###
6072

6173
:: convert install.wim to install.esd
@@ -67,7 +79,7 @@ set wim2esd=0
6779
set wim2swm=0
6880

6981
:: create new iso file
70-
:: require Win10 ADK, or place oscdimg.exe or cdimage.exe next to the script, or inside bin folder
82+
:: require either of: Win10 ADK, oscdimg.exe, cdimage.exe, Windows Powershell
7183
set ISO=1
7284

7385
:: folder path for iso file, leave it blank to create ISO in the script current directory
@@ -235,6 +247,8 @@ iso
235247
isodir
236248
delete_source
237249
autostart
250+
adddrivers
251+
drv_source
238252
) do (
239253
call :ReadINI %%#
240254
)
@@ -264,6 +278,8 @@ if "%UseWimlib%"=="" set UseWimlib=1
264278
if "%ISO%"=="" set ISO=1
265279
if "%AutoStart%"=="" set AutoStart=0
266280
if "%Delete_Source%"=="" set Delete_Source=0
281+
if "%AddDrivers%"=="" set AddDrivers=0
282+
if "%Drv_Source%"=="" set "Drv_Source=\Drivers"
267283
if "%wim2esd%"=="" set wim2esd=0
268284
if "%wim2swm%"=="" set wim2swm=0
269285
set _wlib=0
@@ -276,6 +292,17 @@ if exist "wimlib-imagex.exe" set _wlib=1&set _wimlib="!_work!\wimlib-imagex.exe"
276292
if exist "bin\wimlib-imagex.exe" set _wlib=1&set _wimlib="!_work!\bin\wimlib-imagex.exe"
277293
if /i %xOS%==amd64 if exist "bin\bin64\wimlib-imagex.exe" set _wlib=1&set _wimlib="!_work!\bin\bin64\wimlib-imagex.exe"
278294
)
295+
if "!Drv_Source!"=="\Drivers" set "Drv_Source=!_work!\Drivers"
296+
set "DrvSrcALL="
297+
set "DrvSrcOS="
298+
set "DrvSrcPE="
299+
if %AddDrivers% neq 0 if exist "!Drv_Source!\" (
300+
cd /d "!Drv_Source!"
301+
if exist ALL\ dir /b /s "ALL\*.inf" %_Nul3% && set "DrvSrcALL=!Drv_Source!\ALL"
302+
if exist OS\ dir /b /s "OS\*.inf" %_Nul3% && set "DrvSrcOS=!Drv_Source!\OS"
303+
if exist WinPE\ dir /b /s "WinPE\*.inf" %_Nul3% && set "DrvSrcPE=!Drv_Source!\WinPE"
304+
cd /d "!_work!"
305+
)
279306
set _ADK=0
280307
set "showdism=Host OS"
281308
set "_dism2=%dismroot% /English /NoRestart /ScratchDir"
@@ -538,6 +565,9 @@ set "target=!_work!\DVD10UI"
538565
)
539566
call :extract
540567
if %_sum%==0 goto :fin
568+
if %_build% geq 22000 (
569+
if %LCUwinre% equ 2 (set LCUwinre=0) else (set LCUwinre=1)
570+
)
541571

542572
:igonline
543573
if %online%==0 goto :igoffline
@@ -892,11 +922,15 @@ if %_extsafe%==1 (
892922
%_exp% -f:*_microsoft-windows-sysreset_*.manifest "!repo!\!package!" "checker" %_Null%
893923
if exist "checker\*_microsoft-windows-sysreset_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[SafeOS DU]"
894924
)
895-
if %_extsafe%==1 if not exist "checker\*_microsoft-windows-sysreset_*.manifest" (
925+
if %_extsafe%==1 if not defined _type (
926+
%_exp% -f:*_microsoft-windows-winpe_tools_*.manifest "!repo!\!package!" "checker" %_Null%
927+
if exist "checker\*_microsoft-windows-winpe_tools_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[SafeOS DU]"
928+
)
929+
if %_extsafe%==1 if not defined _type (
896930
%_exp% -f:*_microsoft-windows-winre-tools_*.manifest "!repo!\!package!" "checker" %_Null%
897931
if exist "checker\*_microsoft-windows-winre-tools_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[SafeOS DU]"
898932
)
899-
if %_extsafe%==1 if not exist "checker\*_microsoft-windows-sysreset_*.manifest" (
933+
if %_extsafe%==1 if not defined _type (
900934
%_exp% -f:*_microsoft-windows-i..dsetup-rejuvenation_*.manifest "!repo!\!package!" "checker" %_Null%
901935
if exist "checker\*_microsoft-windows-i..dsetup-rejuvenation_*.manifest" findstr /i /m "Package_for_RollupFix" "checker\update.mum" %_Nul3% || set "_type=[SafeOS DU]"
902936
)
@@ -1228,7 +1262,7 @@ set doboot=0
12281262
set doinstall=0
12291263
if defined cumulative if exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
12301264
if %verb%==0 if %LCUwinre%==1 set dowinre=1
1231-
if %verb%==1 if %_build% neq 14393 set doboot=1
1265+
if %verb%==1 set doboot=1
12321266
)
12331267
if defined cumulative if not exist "!mumtarget!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
12341268
if %verb%==1 set doinstall=1
@@ -1435,13 +1469,18 @@ if %verb%==1 (set /a _sum-=1&goto :eof)
14351469
set "safeos=!safeos! /PackagePath:%dest%\update.mum"
14361470
goto :eof
14371471
)
1438-
if exist "%dest%\*_microsoft-windows-winre-tools_*.manifest" if not exist "%dest%\*_microsoft-windows-sysreset_*.manifest" findstr /i /m "Package_for_RollupFix" "%dest%\update.mum" %_Nul3% || (
1472+
if exist "%dest%\*_microsoft-windows-winpe_tools_*.manifest" if not exist "%dest%\*_microsoft-windows-sysreset_*.manifest" findstr /i /m "Package_for_RollupFix" "%dest%\update.mum" %_Nul3% || (
1473+
if %verb%==1 (set /a _sum-=1&goto :eof)
1474+
set "safeos=!safeos! /PackagePath:%dest%\update.mum"
1475+
goto :eof
1476+
)
1477+
if exist "%dest%\*_microsoft-windows-winre-tools_*.manifest" if not exist "%dest%\*_microsoft-windows-sysreset_*.manifest" if not exist "%dest%\*_microsoft-windows-winpe_tools_*.manifest" findstr /i /m "Package_for_RollupFix" "%dest%\update.mum" %_Nul3% || (
14391478
if not exist "!mumtarget!\Windows\Servicing\Packages\WinPE-SRT-Package~*.mum" (set /a _sum-=1&goto :eof)
14401479
if %verb%==1 (set /a _sum-=1&goto :eof)
14411480
set "safeos=!safeos! /PackagePath:%dest%\update.mum"
14421481
goto :eof
14431482
)
1444-
if exist "%dest%\*_microsoft-windows-i..dsetup-rejuvenation_*.manifest" if not exist "%dest%\*_microsoft-windows-sysreset_*.manifest" if not exist "%dest%\*_microsoft-windows-winre-tools_*.manifest" findstr /i /m "Package_for_RollupFix" "%dest%\update.mum" %_Nul3% || (
1483+
if exist "%dest%\*_microsoft-windows-i..dsetup-rejuvenation_*.manifest" if not exist "%dest%\*_microsoft-windows-sysreset_*.manifest" if not exist "%dest%\*_microsoft-windows-winpe_tools_*.manifest" if not exist "%dest%\*_microsoft-windows-winre-tools_*.manifest" findstr /i /m "Package_for_RollupFix" "%dest%\update.mum" %_Nul3% || (
14451484
if not exist "!mumtarget!\Windows\Servicing\Packages\WinPE-Rejuv-Package~*.mum" (set /a _sum-=1&goto :eof)
14461485
if %verb%==1 (set /a _sum-=1&goto :eof)
14471486
set "safeos=!safeos! /PackagePath:%dest%\update.mum"
@@ -2036,6 +2075,7 @@ echo ============================================================
20362075
echo.
20372076
copy /y "!_work!\winre.wim" "!mountdir!\Windows\System32\Recovery\"
20382077
)
2078+
if %AddDrivers%==1 call :doDrv
20392079
echo.
20402080
echo ============================================================
20412081
echo Unmounting %_wimfile% - index %%#/%imgcount%
@@ -2216,6 +2256,7 @@ goto :eof
22162256
if %errorlevel% neq 0 goto :E_MOUNT
22172257
cd /d "!_cabdir!"
22182258
call :doupdate winre
2259+
if %AddDrivers%==1 call :reDrv
22192260
if !discardre!==1 (
22202261
%_dism2%:"!_cabdir!" /Unmount-Wim /MountDir:"!winremount!" /Discard
22212262
if !errorlevel! neq 0 goto :E_MOUNT
@@ -2236,6 +2277,37 @@ goto :eof
22362277
set dismtarget=/image:"!mountdir!"
22372278
goto :eof
22382279

2280+
:doDrv
2281+
if exist "!mountdir!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
2282+
if not defined DrvSrcALL if not defined DrvSrcPE goto :eof
2283+
) else (
2284+
if not defined DrvSrcALL if not defined DrvSrcOS goto :eof
2285+
)
2286+
echo.
2287+
echo ============================================================
2288+
echo Adding drivers...
2289+
echo ============================================================
2290+
if exist "!mountdir!\Windows\Servicing\Packages\*WinPE-LanguagePack*.mum" (
2291+
if defined DrvSrcALL %_dism2%:"!_cabdir!" %dismtarget% /LogPath:"%_dLog%\DrvWinPE.log" /Add-Driver /Driver:"!DrvSrcALL!" /Recurse
2292+
if defined DrvSrcPE %_dism2%:"!_cabdir!" %dismtarget% /LogPath:"%_dLog%\DrvWinPE.log" /Add-Driver /Driver:"!DrvSrcPE!" /Recurse
2293+
) else (
2294+
if defined DrvSrcALL %_dism2%:"!_cabdir!" %dismtarget% /LogPath:"%_dLog%\DrvOS.log" /Add-Driver /Driver:"!DrvSrcALL!" /Recurse
2295+
if defined DrvSrcOS %_dism2%:"!_cabdir!" %dismtarget% /LogPath:"%_dLog%\DrvOS.log" /Add-Driver /Driver:"!DrvSrcOS!" /Recurse
2296+
)
2297+
if !discard!==1 (
2298+
%_dism2%:"!_cabdir!" /Commit-Wim /MountDir:"!mountdir!"
2299+
)
2300+
goto :eof
2301+
2302+
:reDrv
2303+
if not defined DrvSrcALL if not defined DrvSrcPE goto :eof
2304+
if defined DrvSrcALL %_dism2%:"!_cabdir!" %dismtarget% /LogPath:"%_dLog%\DrvWinRE.log" /Add-Driver /Driver:"!DrvSrcALL!" /Recurse
2305+
if defined DrvSrcPE %_dism2%:"!_cabdir!" %dismtarget% /LogPath:"%_dLog%\DrvWinRE.log" /Add-Driver /Driver:"!DrvSrcPE!" /Recurse
2306+
if !discardre!==1 (
2307+
%_dism2%:"!_cabdir!" /Commit-Wim /MountDir:"!winremount!"
2308+
)
2309+
goto :eof
2310+
22392311
:cleanup
22402312
set savc=0&set savr=1
22412313
if %_build% geq 18362 (set savc=3&set savr=3)
@@ -2940,11 +3012,9 @@ $DirectoryName = $CabFile.Substring(0, $CabFile.LastIndexOf('.'))
29403012
$PSFFile = $DirectoryName + ".psf"
29413013
$null = [IO.Directory]::CreateDirectory($DirectoryName)
29423014
$DeltaList = G $DirectoryName
2943-
$AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1)
2944-
$ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False)
2945-
$TypeBuilder = $ModuleBuilder.DefineType(0)
2946-
[void]$TypeBuilder.DefinePInvokeMethod('ApplyDeltaW', 'msdelta.dll', 'Public, Static', 1, [int], @([Int64], [String], [String], [String]), 1, 3)
2947-
$MSD = $TypeBuilder.CreateType()
3015+
$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0)
3016+
[void]$TB.DefinePInvokeMethod('ApplyDeltaW', 'msdelta.dll', 'Public, Static', 1, [int], @([Int64], [String], [String], [String]), 1, 3)
3017+
$MSD = $TB.CreateType()
29483018
$PSFFileStream = [IO.File]::OpenRead([IO.Path]::GetFullPath($PSFFile))
29493019
$cwd = [IO.Path]::GetFullPath($DirectoryName)
29503020
[Environment]::CurrentDirectory = $cwd
@@ -2979,15 +3049,23 @@ $null = [IO.Directory]::Delete("000", $True)
29793049
:wimmsu:
29803050
function E($WimPath, $InnFile, $OutFile) {
29813051
$DllPath = 'wimgapi.dll'
2982-
$AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1)
2983-
$ModuleBuilder = $AssemblyBuilder.DefineDynamicModule(2, $False)
2984-
$TypeBuilder = $ModuleBuilder.DefineType(0)
2985-
[void]$TypeBuilder.DefinePInvokeMethod('WIMCreateFile', $DllPath, 'Public, Static', 1, [IntPtr], @([String], [UInt32], [Int32], [Int32], [Int32], [Int32].MakeByRefType()), 1, 3).SetImplementationFlags(128)
2986-
[void]$TypeBuilder.DefinePInvokeMethod('WIMLoadImage', $DllPath, 'Public, Static', 1, [IntPtr], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128)
2987-
[void]$TypeBuilder.DefinePInvokeMethod('WIMSetTemporaryPath', $DllPath, 'Public, Static', 1, [int], @([IntPtr], [String]), 1, 3)
2988-
[void]$TypeBuilder.DefinePInvokeMethod('WIMExtractImagePath', $DllPath, 'Public, Static', 1, [int], @([IntPtr], [String], [String], [Int32]), 1, 3)
2989-
[void]$TypeBuilder.DefinePInvokeMethod('WIMCloseHandle', $DllPath, 'Public, Static', 1, [int], @([IntPtr]), 1, 3)
2990-
$WIMG = $TypeBuilder.CreateType()
3052+
$TB = [AppDomain]::CurrentDomain.DefineDynamicAssembly(4, 1).DefineDynamicModule(2, $False).DefineType(0)
3053+
$FN = @(
3054+
'WIMCreateFile;IntPtr;String, UInt32, Int32, Int32, Int32, Int32#Ref;128',
3055+
'WIMLoadImage;IntPtr;IntPtr, Int32;128',
3056+
'WIMSetTemporaryPath;int;IntPtr, String;0',
3057+
'WIMExtractImagePath;int;IntPtr, String, String, Int32;0',
3058+
'WIMCloseHandle;int;IntPtr;0'
3059+
)
3060+
foreach ($str in $FN) {
3061+
$m=$str -split ';'
3062+
$r=$m[1] -as [Type]
3063+
$f=$m[3] -as [int]
3064+
$p = [Collections.ArrayList]@()
3065+
$m[2] -split ', ' | % { $i = $_ -split '#'; if ($null -eq $i[1]) {$p += ($_ -as [type])} else {$p += (($i[0] -as [type]).MakeByRefType())} }
3066+
[void]$TB.DefinePInvokeMethod($m[0], $DllPath, 22, 1, $r, $p, 1, 3).SetImplementationFlags($f)
3067+
}
3068+
$WIMG = $TB.CreateType()
29913069
$hWim = 0
29923070
$hImage = 0
29933071
$hWim = $WIMG::WIMCreateFile($WimPath, "0x80000000", 3, "0x20000000", 0, [ref]$null)

W10MUI/Updates/W10UI.ini

+3
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ ISODir =
2424
Delete_Source =0
2525

2626
AutoStart =0
27+
28+
AddDrivers =0
29+
Drv_Source =\Drivers

W10UI/README.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ avoid using them with the script and install them manually
6363

6464
* Press zero '0' to start the process
6565

66-
* At the end, Press 9 to exit, or close the windows with red X button
66+
* At the end, Press 9 or q to exit, or close the windows with red X button
6767

6868
## Options:
6969

@@ -162,6 +162,25 @@ the option will also auto exit at the end without prompt
162162
* UseWimlib
163163
detect and use wimlib-imagex.exe for exporting wim files instead dism.exe
164164

165+
* AddDrivers
166+
add drivers to install.wim and boot.wim / winre.wim
167+
> this is basic feature support, and should be used only with tested working compatible drivers.
168+
it is ment for simple and boot critical drivers (chipsets, disk controllers, LAN/WiFi..), to allow easier installation, not for large drivers, or drivers that may break setup.
169+
it will not check or verify drivers, it simply point DISM towards the drivers folders.
170+
171+
How To Use:
172+
173+
enable "AddDrivers" option
174+
175+
place the drivers you want to add inside the proper subfolder:
176+
> ALL / drivers will be added to all wim files
177+
OS / drivers will be added to install.wim only
178+
WinPE / drivers will be added to boot.wim / winre.wim only
179+
180+
* Drv_Source
181+
optional, specify different source folder path for drivers
182+
the folder must contain subfolder for each drivers target, as explained above.
183+
165184
- Note: Do not change the structure of W10UI.ini, just set your options after the equal sign `=`
166185

167186
- To restore old behavior and change options by editing the script, simply detele W10UI.ini file
@@ -193,6 +212,10 @@ wait until command prompt window is closed and W10UI_Debug.log is created
193212

194213
<details><summary>changelog</summary>
195214

215+
10.39:
216+
- Implemented basic support to Add Drivers to install.wim and boot.wim / winre.wim
217+
- Updated detection for SafeOS DU
218+
196219
10.38:
197220
- Fixed processing SSU-*.cab from normally-named SSU msu
198221
- Changed 22631 iso label to 23h2_ni_release

0 commit comments

Comments
 (0)