Browse Source

20250828

master
abbodi1406 3 weeks ago
parent
commit
3a08091fcf
  1. 4
      W10UI/README.md
  2. 25
      WHD-W7UI/README.md
  3. 52
      WHD-W7UI/WHD-W7UI.cmd
  4. 59
      WHD-W7UI/WHD-W7UI_WithoutKB3125574.cmd
  5. 22
      WHD-W8.1UI/README.md
  6. 64
      WHD-W8.1UI/WHD-W81UI.cmd

4
W10UI/README.md

@ -32,8 +32,8 @@ you must run W10UI.cmd at least once after restart to perform Cleanup or Reset O @@ -32,8 +32,8 @@ you must run W10UI.cmd at least once after restart to perform Cleanup or Reset O
* Creating updated iso file for a distribution target require either of:
> install Windows ADK
place oscdimg.exe or cdimage.exe in the same folder next to W10UI.cmd
otherwise, embedded Powershell/.NET function `DIR2ISO` will be used to create the iso
place oscdimg.exe or cdimage.exe in the same folder next to W10UI.cmd
* Otherwise, embedded Powershell/.NET function `DIR2ISO` will be used to create the iso
## Limitations:

25
WHD-W7UI/README.md

@ -17,6 +17,13 @@ Automated batch script to install/integrate Windows 7 Updates, depending on WHDo @@ -17,6 +17,13 @@ Automated batch script to install/integrate Windows 7 Updates, depending on WHDo
* Detect Windows 10 ADK [imagex.exe and oscdimg.exe](https://docs.microsoft.com/en-us/windows-hardware/get-started/adk-install) for iso/wim updating
## Updated ISO recommendation:
* Creating updated iso file for a distribution target require either of:
> install Windows ADK
place oscdimg.exe or cdimage.exe in the same folder next to W10UI.cmd
* Otherwise, embedded Powershell/.NET function `DIR2ISO` will be used to create the iso
## How to:
* Recommended Host OS: Windows 7 or Windows 8.1
@ -135,7 +142,6 @@ RSAT @@ -135,7 +142,6 @@ RSAT
- ISO
create new iso file, if the target is a distribution
require installed ADK, or place oscdimg.exe or cdimage.exe next to the script
- ISODir
folder path for iso file, leave it blank to create in the script current directory
@ -191,14 +197,21 @@ if you do not want these settings, edit the script, search for this line and del @@ -191,14 +197,21 @@ if you do not want these settings, edit the script, search for this line and del
## Credits:
[Creator](https://forums.mydigitallife.net/members/abbodi1406.204274/)
[Installer Concept](https://forums.mydigitallife.net/members/burfadel.84828/)
ESUpdates Concept: IMI Kurwica
[Special assistance](http://www.windows-update-checker.com/)
[WHDownloader](https://forums.mydigitallife.net/threads/44645)
Concept - [burfadel](https://forums.mydigitallife.net/members/burfadel.84828/)
ESUpdates Concept / WinSxS Suppressors - [asdcorp](https://github.com/asdcorp/haveSxS)
NoKeyChannel ei.cfg - [awuctl](https://github.com/awuctl)
Special assistance - [komm](http://www.windows-update-checker.com/)
DIR2ISO - [AveYo](https://github.com/AveYo)
WHDownloader - [Alphawaves](https://forums.mydigitallife.net/threads/44645/)
## Changelog:
* 7.0:
- Add "QualityCompat" registry to fix Windows Update supersedence chain metadata
- Implement "DIR2ISO" function by AveYo to create iso (if oscdimg/cdimage are not detected)
- Fix rebuilding boot.wim
- Delete ei.cfg if install.wim have multiple images
* 6.8:
few code improvements and fixes
add option "WimCreateTime"

52
WHD-W7UI/WHD-W7UI.cmd

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
@setlocal DisableDelayedExpansion
@set uiv=v6.8
@set uiv=v7.0
@echo off
:: enable debug mode, you must also set target and repo (if updates folder is not beside the script)
set _Debug=0
@ -1369,6 +1369,7 @@ set ksub1=OFFSOFT&set ksub2=OFFSYST @@ -1369,6 +1369,7 @@ set ksub1=OFFSOFT&set ksub2=OFFSYST
reg.exe load HKLM\!ksub1! "!mountdir!\Windows\System32\config\SOFTWARE"
reg.exe load HKLM\!ksub2! "!mountdir!\Windows\System32\config\SYSTEM"
)
reg.exe add HKLM\%ksub1%\Microsoft\Windows\CurrentVersion\QualityCompat /v cadca5fe-87d3-4b96-b7fb-a231484277cc /t REG_DWORD /d 0 /f
reg.exe add HKLM\%ksub1%\Policies\Microsoft\Windows\Gwx /v DisableGwx /t REG_DWORD /d 1 /f
reg.exe add HKLM\%ksub1%\Policies\Microsoft\Windows\WindowsUpdate /v DisableOSUpgrade /t REG_DWORD /d 1 /f
reg.exe delete HKLM\%ksub1%\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade /f
@ -1700,14 +1701,14 @@ dism.exe /english /get-wiminfo /wimfile:"!mountdir!\Windows\System32\Recovery\wi @@ -1700,14 +1701,14 @@ dism.exe /english /get-wiminfo /wimfile:"!mountdir!\Windows\System32\Recovery\wi
set "mountdir=!mountdib!"
set dismtarget=/image:"!mountdib!"
if %winbuild% lss 9600 if %_ADK% equ 0 if /i "!DismRoot!"=="dism.exe" if not exist "!_imagex!" goto :eof
call :pebuild winre 1
call :pebuild 1 winre
set "_wimfile=!_wimfilb!"
set "_wimpath=!_wimpatb!"
goto :eof
:pebuild
set verb=1
if not "%1"=="" (
if not "%2"=="" (
set verb=0
set "_wimfilb=!_wimfile!"
set "_wimfile=winre.wim"
@ -1722,7 +1723,7 @@ echo ============================================================ @@ -1722,7 +1723,7 @@ echo ============================================================
)
cd /d "!_wimpath!"
if %winbuild% geq 9600 (
for /L %%# in (1,1,%2) do %_dism2%:"!cab_dir!" /Export-Image /SourceImageFile:%_wimfile% /SourceIndex:%%# /DestinationImageFile:temp.wim
for /L %%# in (1,1,%1) do %_dism2%:"!cab_dir!" /Export-Image /SourceImageFile:%_wimfile% /SourceIndex:%%# /DestinationImageFile:temp.wim
if !errorlevel! equ 0 (move /y temp.wim %_wimfile% %_Nul1%) else (del /f /q temp.wim %_Nul3%)
goto :eof
)
@ -1740,6 +1741,8 @@ echo Rebuilding %_wimfile% @@ -1740,6 +1741,8 @@ echo Rebuilding %_wimfile%
echo ============================================================
)
cd /d "!_wimpath!"
for /f "tokens=2 delims=: " %%# in ('dism.exe /english /get-wiminfo /wimfile:"%_wimfile%" ^| find /i "Index"') do set finalimages=%%#
if %dvd%==1 if %finalimages% gtr 1 if exist "sources\ei.cfg" del /f /q sources\ei.cfg
if %winbuild% geq 9600 (
if %keep%==1 (
for %%# in (%indices%) do %_dism2%:"!cab_dir!" /Export-Image /SourceImageFile:%_wimfile% /SourceIndex:%%# /DestinationImageFile:temp.wim
@ -2098,11 +2101,14 @@ if errorlevel 1 goto :targetmenu @@ -2098,11 +2101,14 @@ if errorlevel 1 goto :targetmenu
goto :mainmenu
:ISO
if not exist "!_oscdimg!" if not exist "!_work!\oscdimg.exe" if not exist "!_work!\cdimage.exe" goto :eof
set imapi=0
if not exist "!_oscdimg!" if not exist "!_work!\oscdimg.exe" if not exist "!_work!\bin\oscdimg.exe" if not exist "!_work!\cdimage.exe" if not exist "!_work!\bin\cdimage.exe" set imapi=1
if %imapi%==1 if %_pwsh% equ 0 goto :eof
if "!isodir!"=="" set "isodir=!_work!"
call :DATEISO
if %_cwmi% equ 1 for /f "tokens=2 delims==." %%# in ('wmic os get localdatetime /value') do set "_date=%%#"
if %_cwmi% equ 0 for /f "tokens=1 delims=." %%# in ('%_psc% "([WMI]'Win32_OperatingSystem=@').LocalDateTime"') do set "_date=%%#"
if not defined _date set "_date=000000000000"
if not defined isodate set "isodate=%_date:~2,6%-%_date:~8,4%"
for %%# in (A,B,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 (
set isolab=!isolab:%%#=%%#!
@ -2125,11 +2131,16 @@ echo "!isodir!" @@ -2125,11 +2131,16 @@ echo "!isodir!"
if exist "!_oscdimg!" (set _ff="!_oscdimg!") else if exist "!_work!\oscdimg.exe" (set _ff="!_work!\oscdimg.exe") else (set _ff="!_work!\cdimage.exe")
cd /d "!target!"
if exist "efi\microsoft\boot\efisys.bin" (
!_ff! -bootdata:2#p0,e,b".\boot\etfsboot.com"#pEF,e,b".\efi\microsoft\boot\efisys.bin" -o -m -u2 -udfver102 -l"%isover%" . "%isofile%"
set "_b_=-bootdata:2#p0,e,b".\boot\etfsboot.com"#pEF,e,b".\efi\microsoft\boot\efisys.bin""
) else (
set "_b_=-b".\boot\etfsboot.com""
)
if %imapi%==0 (
!_ff! %_b_% -o -m -u2 -udfver102 -l"%isover%" . "%isofile%"
) else (
!_ff! -b".\boot\etfsboot.com" -o -m -u2 -udfver102 -l"%isover%" . "%isofile%"
call :DIR2ISO . "%isofile%" 0 "%isover%"
)
set errcode=%errorlevel%
call set errcode=!errorlevel!
if not exist "%isofile%" set errcode=1
if %errcode% equ 0 move /y "%isofile%" "!isodir!\" %_Nul3%
cd /d "!_work!"
@ -2192,6 +2203,31 @@ echo Press 9 or q to exit. @@ -2192,6 +2203,31 @@ echo Press 9 or q to exit.
choice /c 9Q /n
if errorlevel 1 (goto :eof) else (rem.)
$:DIR2ISO: #,# [PARAMS] directory file.iso
set ^ #=& set 1=%*& set "0=%~f0"& powershell -nop -c "$f0=[IO.File]::ReadAllText($env:0); $0=($f0 -split '\$%0:.*')[1]; $1=$env:1 -replace '([`@$])','`$1'; iex(\"$0 `r`n %0 $1\")"& exit /b !errorlevel!
[Environment]::CurrentDirectory = (Get-Location -PSProvider FileSystem).ProviderPath
function :DIR2ISO ($dir, $iso, $efi=0, $vol='DVD_ROM') { if (!(test-path -Path $dir -pathtype Container)) {"[ERR] $dir\ :DIR2ISO";exit 1}; $dir2iso=@"
using System; using System.IO; using System.Runtime.Interop`Services; using System.Runtime.Interop`Services.ComTypes;
public class dir2iso {public int AveYo=2021; [Dll`Import("shlwapi",CharSet=CharSet.Unicode,PreserveSig=false)]
internal static extern void SHCreateStreamOnFileEx(string f,uint m,uint d,bool b,IStream r,out IStream s);
public static void Create(string file, ref object obj, int bs, int tb) { IStream dir=(IStream)obj, iso;
try {SHCreateStreamOnFileEx(file,0x1001,0x80,true,null,out iso);} catch(Exception e) {Console.WriteLine(e.Message); return;}
int d=tb>1024 ? 1024 : 1, pad=tb%d, block=bs*d, total=(tb-pad)/d, c=total>100 ? total/100 : total, i=1, MB=(bs/1024)*tb/1024;
Console.Write("{0,3}% {1}MB {2}",0,MB,file); if (pad > 0) dir.CopyTo(iso, pad * block, Int`Ptr.Zero, Int`Ptr.Zero);
while (total-- > 0) {dir.CopyTo(iso, block, Int`Ptr.Zero, Int`Ptr.Zero); if (total % c == 0) {Console.Write("\r{0,3}%",i++);}}
iso.Commit(0); Console.WriteLine("\r{0,3}% {1}MB {2}", 100, MB, file); } }
"@; & { $cs=new-object CodeDom.Compiler.CompilerParameters; $cs.GenerateInMemory=1 #,# no`warnings
$compile=(new-object Microsoft.CSharp.CSharpCodeProvider).CompileAssemblyFromSource($cs, $dir2iso)
$BOOT=@(); $bootable=0; if ($efi) {$idx=0; $mbr_efi=@(0xEF); $images=@('efi\microsoft\boot\efisys.bin')} else {$idx=0,1; $mbr_efi=@(0,0xEF); $images=@('boot\etfsboot.com','efi\microsoft\boot\efisys.bin')}
$idx|% { $bootimage=join-path $dir -child $images[$_]; if (test-path -Path $bootimage -pathtype Leaf) {
$bin=new-object -ComObject ADODB.Stream; $bin.Open(); $bin.Type=1; $bin.LoadFromFile($bootimage)
$opt=new-object -ComObject IMAPI2FS.BootOptions; $opt.AssignBootImage($bin.psobject.BaseObject); $opt.Manufacturer='Microsoft'
$opt.PlatformId=$mbr_efi[$_]; $opt.Emulation=0; $bootable=1; $BOOT += $opt.psobject.BaseObject } }
$fsi=new-object -ComObject IMAPI2FS.MsftFileSystemImage; $fsi.FileSystemsToCreate=4; $fsi.FreeMediaBlocks=0; $fsi.UDFRevision=0x102
if ($bootable) {$fsi.BootImageOptionsArray=$BOOT}; $CONTENT=$fsi.Root; $CONTENT.AddTree($dir,$false); $fsi.VolumeName=$vol
$obj=$fsi.CreateResultImage(); [dir2iso]::Create($iso,[ref]$obj.ImageStream,$obj.BlockSize,$obj.TotalBlocks) };[GC]::Collect()
} $:DIR2ISO: #,# export directory as (bootable) udf iso - lean and mean snippet by AveYo, 2021
:EndDebug
cmd /u /c type "!_log!_tmp.log">"!_log!_Debug.log"
(goto) &del "!_log!_tmp.log"

59
WHD-W7UI/WHD-W7UI_WithoutKB3125574.cmd

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
@setlocal DisableDelayedExpansion
@set uiv=v6.8
@set uiv=v7.0
@echo off
:: enable debug mode, you must also set target and repo (if updates folder is not beside the script)
set _Debug=0
@ -1388,6 +1388,7 @@ set ksub1=OFFSOFT&set ksub2=OFFSYST @@ -1388,6 +1388,7 @@ set ksub1=OFFSOFT&set ksub2=OFFSYST
reg.exe load HKLM\!ksub1! "!mountdir!\Windows\System32\config\SOFTWARE"
reg.exe load HKLM\!ksub2! "!mountdir!\Windows\System32\config\SYSTEM"
)
reg.exe add HKLM\%ksub1%\Microsoft\Windows\CurrentVersion\QualityCompat /v cadca5fe-87d3-4b96-b7fb-a231484277cc /t REG_DWORD /d 0 /f
reg.exe add HKLM\%ksub1%\Policies\Microsoft\Windows\Gwx /v DisableGwx /t REG_DWORD /d 1 /f
reg.exe add HKLM\%ksub1%\Policies\Microsoft\Windows\WindowsUpdate /v DisableOSUpgrade /t REG_DWORD /d 1 /f
reg.exe delete HKLM\%ksub1%\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade /f
@ -1719,14 +1720,14 @@ dism.exe /english /get-wiminfo /wimfile:"!mountdir!\Windows\System32\Recovery\wi @@ -1719,14 +1720,14 @@ dism.exe /english /get-wiminfo /wimfile:"!mountdir!\Windows\System32\Recovery\wi
set "mountdir=!mountdib!"
set dismtarget=/image:"!mountdib!"
if %winbuild% lss 9600 if %_ADK% equ 0 if /i "!DismRoot!"=="dism.exe" if not exist "!_imagex!" goto :eof
call :pebuild winre 1
call :pebuild 1 winre
set "_wimfile=!_wimfilb!"
set "_wimpath=!_wimpatb!"
goto :eof
:pebuild
set verb=1
if not "%1"=="" (
if not "%2"=="" (
set verb=0
set "_wimfilb=!_wimfile!"
set "_wimfile=winre.wim"
@ -1741,7 +1742,7 @@ echo ============================================================ @@ -1741,7 +1742,7 @@ echo ============================================================
)
cd /d "!_wimpath!"
if %winbuild% geq 9600 (
for /L %%# in (1,1,%2) do %_dism2%:"!cab_dir!" /Export-Image /SourceImageFile:%_wimfile% /SourceIndex:%%# /DestinationImageFile:temp.wim
for /L %%# in (1,1,%1) do %_dism2%:"!cab_dir!" /Export-Image /SourceImageFile:%_wimfile% /SourceIndex:%%# /DestinationImageFile:temp.wim
if !errorlevel! equ 0 (move /y temp.wim %_wimfile% %_Nul1%) else (del /f /q temp.wim %_Nul3%)
goto :eof
)
@ -1759,6 +1760,8 @@ echo Rebuilding %_wimfile% @@ -1759,6 +1760,8 @@ echo Rebuilding %_wimfile%
echo ============================================================
)
cd /d "!_wimpath!"
for /f "tokens=2 delims=: " %%# in ('dism.exe /english /get-wiminfo /wimfile:"%_wimfile%" ^| find /i "Index"') do set finalimages=%%#
if %dvd%==1 if %finalimages% gtr 1 if exist "sources\ei.cfg" del /f /q sources\ei.cfg
if %winbuild% geq 9600 (
if %keep%==1 (
for %%# in (%indices%) do %_dism2%:"!cab_dir!" /Export-Image /SourceImageFile:%_wimfile% /SourceIndex:%%# /DestinationImageFile:temp.wim
@ -2117,9 +2120,14 @@ if errorlevel 1 goto :targetmenu @@ -2117,9 +2120,14 @@ if errorlevel 1 goto :targetmenu
goto :mainmenu
:ISO
if not exist "!_oscdimg!" if not exist "!_work!\oscdimg.exe" if not exist "!_work!\cdimage.exe" goto :eof
set imapi=0
if not exist "!_oscdimg!" if not exist "!_work!\oscdimg.exe" if not exist "!_work!\bin\oscdimg.exe" if not exist "!_work!\cdimage.exe" if not exist "!_work!\bin\cdimage.exe" set imapi=1
if %imapi%==1 if %_pwsh% equ 0 goto :eof
if "!isodir!"=="" set "isodir=!_work!"
for /f "tokens=2 delims==." %%# in ('wmic os get localdatetime /value') do set "_date=%%#"
call :DATEISO
if %_cwmi% equ 1 for /f "tokens=2 delims==." %%# in ('wmic os get localdatetime /value') do set "_date=%%#"
if %_cwmi% equ 0 for /f "tokens=1 delims=." %%# in ('%_psc% "([WMI]'Win32_OperatingSystem=@').LocalDateTime"') do set "_date=%%#"
if not defined _date set "_date=000000000000"
set "isodate=%_date:~0,4%-%_date:~4,2%-%_date:~6,2%"
if defined isover (set isofile=Win7_%isover%_%arch%_%isodate%.iso) else (set isofile=Win7_%arch%_%isodate%.iso)
set /a rnd=%random%
@ -2128,14 +2136,22 @@ echo. @@ -2128,14 +2136,22 @@ echo.
echo ============================================================
echo Creating updated ISO file...
echo ============================================================
echo.
echo ISO Location:
echo "!isodir!"
if exist "!_oscdimg!" (set _ff="!_oscdimg!") else if exist "!_work!\oscdimg.exe" (set _ff="!_work!\oscdimg.exe") else (set _ff="!_work!\cdimage.exe")
cd /d "!target!"
if exist "efi\microsoft\boot\efisys.bin" (
!_ff! -bootdata:2#p0,e,b".\boot\etfsboot.com"#pEF,e,b".\efi\microsoft\boot\efisys.bin" -o -m -u2 -udfver102 -l"%isover%" . "%isofile%"
set "_b_=-bootdata:2#p0,e,b".\boot\etfsboot.com"#pEF,e,b".\efi\microsoft\boot\efisys.bin""
) else (
!_ff! -b".\boot\etfsboot.com" -o -m -u2 -udfver102 -l"%isover%" . "%isofile%"
set "_b_=-b".\boot\etfsboot.com""
)
set errcode=%errorlevel%
if %imapi%==0 (
!_ff! %_b_% -o -m -u2 -udfver102 -l"%isover%" . "%isofile%"
) else (
call :DIR2ISO . "%isofile%" 0 "%isover%"
)
call set errcode=!errorlevel!
if not exist "%isofile%" set errcode=1
if %errcode% equ 0 move /y "%isofile%" "!isodir!\" %_Nul3%
cd /d "!_work!"
@ -2198,6 +2214,31 @@ echo Press 9 or q to exit. @@ -2198,6 +2214,31 @@ echo Press 9 or q to exit.
choice /c 9Q /n
if errorlevel 1 (goto :eof) else (rem.)
$:DIR2ISO: #,# [PARAMS] directory file.iso
set ^ #=& set 1=%*& set "0=%~f0"& powershell -nop -c "$f0=[IO.File]::ReadAllText($env:0); $0=($f0 -split '\$%0:.*')[1]; $1=$env:1 -replace '([`@$])','`$1'; iex(\"$0 `r`n %0 $1\")"& exit /b !errorlevel!
[Environment]::CurrentDirectory = (Get-Location -PSProvider FileSystem).ProviderPath
function :DIR2ISO ($dir, $iso, $efi=0, $vol='DVD_ROM') { if (!(test-path -Path $dir -pathtype Container)) {"[ERR] $dir\ :DIR2ISO";exit 1}; $dir2iso=@"
using System; using System.IO; using System.Runtime.Interop`Services; using System.Runtime.Interop`Services.ComTypes;
public class dir2iso {public int AveYo=2021; [Dll`Import("shlwapi",CharSet=CharSet.Unicode,PreserveSig=false)]
internal static extern void SHCreateStreamOnFileEx(string f,uint m,uint d,bool b,IStream r,out IStream s);
public static void Create(string file, ref object obj, int bs, int tb) { IStream dir=(IStream)obj, iso;
try {SHCreateStreamOnFileEx(file,0x1001,0x80,true,null,out iso);} catch(Exception e) {Console.WriteLine(e.Message); return;}
int d=tb>1024 ? 1024 : 1, pad=tb%d, block=bs*d, total=(tb-pad)/d, c=total>100 ? total/100 : total, i=1, MB=(bs/1024)*tb/1024;
Console.Write("{0,3}% {1}MB {2}",0,MB,file); if (pad > 0) dir.CopyTo(iso, pad * block, Int`Ptr.Zero, Int`Ptr.Zero);
while (total-- > 0) {dir.CopyTo(iso, block, Int`Ptr.Zero, Int`Ptr.Zero); if (total % c == 0) {Console.Write("\r{0,3}%",i++);}}
iso.Commit(0); Console.WriteLine("\r{0,3}% {1}MB {2}", 100, MB, file); } }
"@; & { $cs=new-object CodeDom.Compiler.CompilerParameters; $cs.GenerateInMemory=1 #,# no`warnings
$compile=(new-object Microsoft.CSharp.CSharpCodeProvider).CompileAssemblyFromSource($cs, $dir2iso)
$BOOT=@(); $bootable=0; if ($efi) {$idx=0; $mbr_efi=@(0xEF); $images=@('efi\microsoft\boot\efisys.bin')} else {$idx=0,1; $mbr_efi=@(0,0xEF); $images=@('boot\etfsboot.com','efi\microsoft\boot\efisys.bin')}
$idx|% { $bootimage=join-path $dir -child $images[$_]; if (test-path -Path $bootimage -pathtype Leaf) {
$bin=new-object -ComObject ADODB.Stream; $bin.Open(); $bin.Type=1; $bin.LoadFromFile($bootimage)
$opt=new-object -ComObject IMAPI2FS.BootOptions; $opt.AssignBootImage($bin.psobject.BaseObject); $opt.Manufacturer='Microsoft'
$opt.PlatformId=$mbr_efi[$_]; $opt.Emulation=0; $bootable=1; $BOOT += $opt.psobject.BaseObject } }
$fsi=new-object -ComObject IMAPI2FS.MsftFileSystemImage; $fsi.FileSystemsToCreate=4; $fsi.FreeMediaBlocks=0; $fsi.UDFRevision=0x102
if ($bootable) {$fsi.BootImageOptionsArray=$BOOT}; $CONTENT=$fsi.Root; $CONTENT.AddTree($dir,$false); $fsi.VolumeName=$vol
$obj=$fsi.CreateResultImage(); [dir2iso]::Create($iso,[ref]$obj.ImageStream,$obj.BlockSize,$obj.TotalBlocks) };[GC]::Collect()
} $:DIR2ISO: #,# export directory as (bootable) udf iso - lean and mean snippet by AveYo, 2021
:EndDebug
cmd /u /c type "!_log!_tmp.log">"!_log!_Debug.log"
(goto) &del "!_log!_tmp.log"

22
WHD-W8.1UI/README.md

@ -21,6 +21,13 @@ checked locations: mounted iso, inserted dvd/usb, sxs folder for distribution ta @@ -21,6 +21,13 @@ checked locations: mounted iso, inserted dvd/usb, sxs folder for distribution ta
* Perform pending cleanup operation for online OS after restarting
## Updated ISO recommendation:
* Creating updated iso file for a distribution target require either of:
> install Windows ADK
place oscdimg.exe or cdimage.exe in the same folder next to W10UI.cmd
* Otherwise, embedded Powershell/.NET function `DIR2ISO` will be used to create the iso
## How to:
* Recommended Host OS: Windows 7 or later
@ -133,7 +140,6 @@ warning: the process will consume very high amount of CPU and RAM resources @@ -133,7 +140,6 @@ warning: the process will consume very high amount of CPU and RAM resources
- ISO
create new iso file, if the target is a distribution
require installed ADK, or place oscdimg.exe or cdimage.exe next to the script
- ISODir
folder path for iso file, leave it blank to create in the script current directory
@ -183,12 +189,20 @@ after installing the OS, you need to run it as administrator, it will be self-de @@ -183,12 +189,20 @@ after installing the OS, you need to run it as administrator, it will be self-de
## Credits:
[Creator](https://forums.mydigitallife.net/members/abbodi1406.204274/)
[Concept](https://forums.mydigitallife.net/members/burfadel.84828/)
[WHDownloader](https://forums.mydigitallife.net/threads/44645)
Concept - [burfadel](https://forums.mydigitallife.net/members/burfadel.84828/)
ESUpdates Concept / WinSxS Suppressors - [asdcorp](https://github.com/asdcorp/haveSxS)
NoKeyChannel ei.cfg - [awuctl](https://github.com/awuctl)
Special assistance - [komm](http://www.windows-update-checker.com/)
DIR2ISO - [AveYo](https://github.com/AveYo)
WHDownloader - [Alphawaves](https://forums.mydigitallife.net/threads/44645/)
## Changelog:
* 7.8:
- Add "QualityCompat" registry to fix Windows Update supersedence chain metadata
- Implement "DIR2ISO" function by AveYo to create iso (if oscdimg/cdimage are not detected)
- Create ei.cfg if not exist, or replace it if install.wim have multiple images
* 7.7:
few code improvements and fixes
add option "WimCreateTime"

64
WHD-W8.1UI/WHD-W81UI.cmd

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
@setlocal DisableDelayedExpansion
@set uiv=v7.7
@set uiv=v7.8
@echo off
:: enable debug mode, you must also set target and repo (if updates folder is not beside the script)
set _Debug=0
@ -1092,6 +1092,7 @@ set ksub1=OFFSOFT&set ksub2=OFFSYST @@ -1092,6 +1092,7 @@ set ksub1=OFFSOFT&set ksub2=OFFSYST
reg.exe load HKLM\!ksub1! "!mountdir!\Windows\System32\config\SOFTWARE"
reg.exe load HKLM\!ksub2! "!mountdir!\Windows\System32\config\SYSTEM"
)
reg.exe add HKLM\%ksub1%\Microsoft\Windows\CurrentVersion\QualityCompat /v cadca5fe-87d3-4b96-b7fb-a231484277cc /t REG_DWORD /d 0 /f
reg.exe add HKLM\%ksub1%\Policies\Microsoft\Windows\Gwx /v DisableGwx /t REG_DWORD /d 1 /f
reg.exe add HKLM\%ksub1%\Policies\Microsoft\Windows\WindowsUpdate /v DisableOSUpgrade /t REG_DWORD /d 1 /f
reg.exe delete HKLM\%ksub1%\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade /f
@ -1306,6 +1307,7 @@ if not exist "!mountdir!\" mkdir "!mountdir!" @@ -1306,6 +1307,7 @@ if not exist "!mountdir!\" mkdir "!mountdir!"
if not exist "!cab_dir!\" mkdir "!cab_dir!"
for %%# in (%indices%) do (set "_inx=%%#"&call :dowork)
cd /d "!_work!"
if %dvd%==1 if /i "%_wimfile%"=="sources\install.wim" call :ei_cfg
if %keep%==0 if %wim2esd%==1 if %dvd%==1 if /i "%_wimfile%"=="sources\install.wim" goto :eof
echo.
echo ============================================================
@ -1321,6 +1323,21 @@ if %errorlevel% equ 0 (move /y temp.wim %_wimfile% %_Nul1%) else (del /f /q temp @@ -1321,6 +1323,21 @@ if %errorlevel% equ 0 (move /y temp.wim %_wimfile% %_Nul1%) else (del /f /q temp
cd /d "!_work!"
goto :eof
:ei_cfg
cd /d "!_wimpath!"
for /f "tokens=2 delims=: " %%# in ('dism.exe /english /get-wiminfo /wimfile:"%_wimfile%" ^| find /i "Index"') do set finalimages=%%#
if %finalimages% equ 1 if exist "sources\ei.cfg" exit /b
if exist "sources\ei.cfg" del /f /q sources\ei.cfg
(
echo [Channel]
echo NoKeyChannel
echo.
echo [VL]
echo 0
)>sources\EI.CFG
cd /d "!_work!"
exit /b
:dowork
echo.
echo ============================================================
@ -1789,7 +1806,7 @@ echo. @@ -1789,7 +1806,7 @@ echo.
if /i "!target!"=="%SystemDrive%" (
echo [L] Online installation limit: %onlinelimit% updates
) else (
if %winbuild% lss 9600 (if %_ADK% equ 0 (echo [D] Select Windows 8.1 dism.exe) else (echo [D] DISM: "!showdism!")) else (echo [D] DISM: "!showdism!")
if %winbuild% lss 9600 (if %_ADK% equ 0 (echo [D] Select Windows 10/8.1 dism.exe) else (echo [D] DISM: "!showdism!")) else (echo [D] DISM: "!showdism!")
)
if %wimfiles% equ 1 (
if /i "%targetname%"=="install.wim" (echo.&if %winre%==1 (echo [U] Update WinRE.wim: YES) else (echo [U] Update WinRE.wim: NO))
@ -1829,11 +1846,14 @@ if errorlevel 1 goto :targetmenu @@ -1829,11 +1846,14 @@ if errorlevel 1 goto :targetmenu
goto :mainmenu
:ISO
if not exist "!_oscdimg!" if not exist "!_work!\oscdimg.exe" if not exist "!_work!\cdimage.exe" goto :eof
set imapi=0
if not exist "!_oscdimg!" if not exist "!_work!\oscdimg.exe" if not exist "!_work!\bin\oscdimg.exe" if not exist "!_work!\cdimage.exe" if not exist "!_work!\bin\cdimage.exe" set imapi=1
if %imapi%==1 if %_pwsh% equ 0 goto :eof
if "!isodir!"=="" set "isodir=!_work!"
call :DATEISO
if %_cwmi% equ 1 for /f "tokens=2 delims==." %%# in ('wmic os get localdatetime /value') do set "_date=%%#"
if %_cwmi% equ 0 for /f "tokens=1 delims=." %%# in ('%_psc% "([WMI]'Win32_OperatingSystem=@').LocalDateTime"') do set "_date=%%#"
if not defined _date set "_date=000000000000"
if not defined isodate set "isodate=%_date:~2,6%-%_date:~8,4%"
for %%# in (A,B,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 (
set isolab=!isolab:%%#=%%#!
@ -1855,8 +1875,17 @@ echo ISO Location: @@ -1855,8 +1875,17 @@ echo ISO Location:
echo "!isodir!"
if exist "!_oscdimg!" (set _ff="!_oscdimg!") else if exist "!_work!\oscdimg.exe" (set _ff="!_work!\oscdimg.exe") else (set _ff="!_work!\cdimage.exe")
cd /d "!target!"
!_ff! -bootdata:2#p0,e,b".\boot\etfsboot.com"#pEF,e,b".\efi\microsoft\boot\efisys.bin" -o -m -u2 -udfver102 -l"%isover%" . "%isofile%"
set errcode=%errorlevel%
if exist "efi\microsoft\boot\efisys.bin" (
set "_b_=-bootdata:2#p0,e,b".\boot\etfsboot.com"#pEF,e,b".\efi\microsoft\boot\efisys.bin""
) else (
set "_b_=-b".\boot\etfsboot.com""
)
if %imapi%==0 (
!_ff! %_b_% -o -m -u2 -udfver102 -l"%isover%" . "%isofile%"
) else (
call :DIR2ISO . "%isofile%" 0 "%isover%"
)
call set errcode=!errorlevel!
if not exist "%isofile%" set errcode=1
if %errcode% equ 0 move /y "%isofile%" "!isodir!\" %_Nul3%
cd /d "!_work!"
@ -1919,6 +1948,31 @@ echo Press 9 or q to exit. @@ -1919,6 +1948,31 @@ echo Press 9 or q to exit.
choice /c 9Q /n
if errorlevel 1 (goto :eof) else (rem.)
$:DIR2ISO: #,# [PARAMS] directory file.iso
set ^ #=& set 1=%*& set "0=%~f0"& powershell -nop -c "$f0=[IO.File]::ReadAllText($env:0); $0=($f0 -split '\$%0:.*')[1]; $1=$env:1 -replace '([`@$])','`$1'; iex(\"$0 `r`n %0 $1\")"& exit /b !errorlevel!
[Environment]::CurrentDirectory = (Get-Location -PSProvider FileSystem).ProviderPath
function :DIR2ISO ($dir, $iso, $efi=0, $vol='DVD_ROM') { if (!(test-path -Path $dir -pathtype Container)) {"[ERR] $dir\ :DIR2ISO";exit 1}; $dir2iso=@"
using System; using System.IO; using System.Runtime.Interop`Services; using System.Runtime.Interop`Services.ComTypes;
public class dir2iso {public int AveYo=2021; [Dll`Import("shlwapi",CharSet=CharSet.Unicode,PreserveSig=false)]
internal static extern void SHCreateStreamOnFileEx(string f,uint m,uint d,bool b,IStream r,out IStream s);
public static void Create(string file, ref object obj, int bs, int tb) { IStream dir=(IStream)obj, iso;
try {SHCreateStreamOnFileEx(file,0x1001,0x80,true,null,out iso);} catch(Exception e) {Console.WriteLine(e.Message); return;}
int d=tb>1024 ? 1024 : 1, pad=tb%d, block=bs*d, total=(tb-pad)/d, c=total>100 ? total/100 : total, i=1, MB=(bs/1024)*tb/1024;
Console.Write("{0,3}% {1}MB {2}",0,MB,file); if (pad > 0) dir.CopyTo(iso, pad * block, Int`Ptr.Zero, Int`Ptr.Zero);
while (total-- > 0) {dir.CopyTo(iso, block, Int`Ptr.Zero, Int`Ptr.Zero); if (total % c == 0) {Console.Write("\r{0,3}%",i++);}}
iso.Commit(0); Console.WriteLine("\r{0,3}% {1}MB {2}", 100, MB, file); } }
"@; & { $cs=new-object CodeDom.Compiler.CompilerParameters; $cs.GenerateInMemory=1 #,# no`warnings
$compile=(new-object Microsoft.CSharp.CSharpCodeProvider).CompileAssemblyFromSource($cs, $dir2iso)
$BOOT=@(); $bootable=0; if ($efi) {$idx=0; $mbr_efi=@(0xEF); $images=@('efi\microsoft\boot\efisys.bin')} else {$idx=0,1; $mbr_efi=@(0,0xEF); $images=@('boot\etfsboot.com','efi\microsoft\boot\efisys.bin')}
$idx|% { $bootimage=join-path $dir -child $images[$_]; if (test-path -Path $bootimage -pathtype Leaf) {
$bin=new-object -ComObject ADODB.Stream; $bin.Open(); $bin.Type=1; $bin.LoadFromFile($bootimage)
$opt=new-object -ComObject IMAPI2FS.BootOptions; $opt.AssignBootImage($bin.psobject.BaseObject); $opt.Manufacturer='Microsoft'
$opt.PlatformId=$mbr_efi[$_]; $opt.Emulation=0; $bootable=1; $BOOT += $opt.psobject.BaseObject } }
$fsi=new-object -ComObject IMAPI2FS.MsftFileSystemImage; $fsi.FileSystemsToCreate=4; $fsi.FreeMediaBlocks=0; $fsi.UDFRevision=0x102
if ($bootable) {$fsi.BootImageOptionsArray=$BOOT}; $CONTENT=$fsi.Root; $CONTENT.AddTree($dir,$false); $fsi.VolumeName=$vol
$obj=$fsi.CreateResultImage(); [dir2iso]::Create($iso,[ref]$obj.ImageStream,$obj.BlockSize,$obj.TotalBlocks) };[GC]::Collect()
} $:DIR2ISO: #,# export directory as (bootable) udf iso - lean and mean snippet by AveYo, 2021
:EndDebug
cmd /u /c type "!_log!_tmp.log">"!_log!_Debug.log"
(goto) &del "!_log!_tmp.log"

Loading…
Cancel
Save