我们使用许多版本的Windows NT 6.0+创建安装介质,而无需使用第三方软件

KDPV你好 今天,我将告诉您如何在不使用第三方软件的情况下,使用许多不同版本的Windows创建单个安装媒体。因此,您将完全了解我们执行的操作。


我还要强调一点 熵带给这个世界 更改原始安装发行版的结构。


谁在乎-我要猫。


 


背景知识


在过去的几年中,我仅通过USB驱动器安装Windows NT 6.0+ 操作系统有时,它是闪存驱动器,更常见的是USB-HDD。(接下来,为简单起见,我将USB安装介质称为闪存驱动器)。 但是Windows安装介质中有一个令人不快的功能- 安装文件路径硬编码的至少在闪存驱动器的根目录中应为:

 


[boot]
[sources]
bootmgr

如果您需要UEFI引导(例如,将系统安装在具有GPT分区样式的磁盘上),请添加另一个[efi]


. ? , Windows ! - Win8, Win7 , - ...


ISO- (, Win 8.1 x64). [sources] [sources_w8x64]. ISO- [sources], . . . :
 


[boot]
[sources]
[sources_w7x86]
[sources_w8x64]
[sources_w8x86]
bootmgr

- , , Windows [sources].


. , . , . — LBA, MBR, .. , : , , .. , Windows 10! ! - : 10-, . Media Creation Tool 10-. . , . Visual Studio . :
 


[boot]
[sources]
[sources_w7x64]
[sources_w7x86]
[sources_w8x64]
[sources_w8x86]
[sources_w10x86]
bootmgr

:


!

, , .
: Grub4Dos , ISO, ISO, WinPE, ISO (.. - ), … , ! — USB-HDD, , , … — .


, : ISO-, … …
, .


 




ISO, . ISO ( ), , Windows , (. ).
 
Windows AiO ( sources\install.wim ), , :



    • FAT32, UEFI
  • ( , )
  • , , , Win7 Win10 ( )

还有一件事 , , . , . — !
 
 




- :


  • FAT32
  • exFAT
  • NTFS

FAT32: , UEFI. : — 4 .
exFAT: , UEFI . , (, Grub4Dos) . BOOTMGR . Upd: , Live Linux ISO .
NTFS: , , UEFI .


:
UEFI — FAT32, — NTFS.


.
: , . - ;)
 
 



, (, ...).
USB-HDD .


USB-HDD :
(diskmgmt.msc). USB-HDD " ". — .


. " " . :
(cmd.exe). :
 


DiskPart
list disk
select disk <   (      )>
list part
select part < ,     ( 1)>
active
exit

DiskPart

. . .
 
 




Windows


. :
 


[boot]
[efi] -      UEFI (    FAT32! (      NTFS))
bootmgr
bootmgr.efi -      UEFI (    FAT32! (      NTFS))

— Windows 10 x64 (Threshold 2).


.
— Windows Boot Manager c . — - , [sources]. , bootmgr .
Windows Boot Manager, , BOOTMGR. , bootsect /nt60 <_>:, <_> — .
 
 



[sources]. , [sources] Windows . . . :
 


[WinDists]
 |- [Win_7_ia32]
 |- [Win_7_x64]
 |- [Win_8.1_ia32]
 |- [Win_8.1_x64]
 |- [Win_10_ia32]
 |- [Win_10_x64]

[sources] ISO-. . — .
 
 




, . .. . , Windows.


, ? . :
 


[boot]
 |- bcd
[efi]
 |- [microsoft]
     |- [boot]
         |- bcd -      UEFI (    FAT32! (      NTFS))


BCD


. , ( , ! ◕‿◕).
:
 


bcdedit /store <_>:\boot\bcd /set {bootmgr} DisplayBootMenu True
bcdedit /store <_>:\boot\bcd /deletevalue {bootmgr} Timeout

<_> — .


.
bcdedit /store <_>:\boot\bcd /enum {default}
device osdevice -. :


device      ramdisk=[boot]\sources\boot.wim,{<GUID  ramdisk>}
osdevice    ramdisk=[boot]\sources\boot.wim,{<GUID  ramdisk>}

, .
Windows c WinPE (boot.wim), <GUID ramdisk>. .
 


device , \windows\system32\boot\winload.exe ( path).
osdevice , \windows ( systemroot).


device osdevice WIM- ( WinPE), (ramdisk). GUID , , WinPE ( — ramdisk). :


bcdedit /store <_>:\boot\bcd /enum {<GUID  ramdisk>}

 
-------------------
           {<GUID  ramdisk>}
ramdisksdidevice        boot
ramdisksdipath          \boot\boot.sdi

. .


boot.sdi — - NTFS-. boot.wim.


- ( device osdevice), .
 



  1. -:
    bcdedit /store <_>:\boot\bcd /copy {Default} /d "< >"
    GUID . :
    {<GUID >}
     
  2. :
    bcdedit /store <_>:\boot\bcd /set {<GUID >} device ramdisk=[boot]\< >\boot.wim,{<GUID ramdisk>}
     
    bcdedit /store <_>:\boot\bcd /set {<GUID >} osdevice ramdisk=[boot]\< >\boot.wim,{<GUID ramdisk>}
     
    ().

-.
! GUID-. .


bcdedit /store <_>:\boot\bcd /copy {Default} /d "Windows 7 (32-bit) Setup"
    {90fff3ef-3b91-11e6-839b-d850e607fea0}.

bcdedit /store <_>:\boot\bcd /set {90fff3ef-3b91-11e6-839b-d850e607fea0} device ramdisk=[boot]\WinDists\Win_7_ia32\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
bcdedit /store <_>:\boot\bcd /set {90fff3ef-3b91-11e6-839b-d850e607fea0} osdevice ramdisk=[boot]\WinDists\Win_7_ia32\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}

bcdedit /store <_>:\boot\bcd /copy {Default} /d "Windows 7 (64-bit) Setup"
    {e5f9b9b7-3bb1-11e6-839b-d850e607fea0}.

bcdedit /store <_>:\boot\bcd /set {e5f9b9b7-3bb1-11e6-839b-d850e607fea0} device ramdisk=[boot]\WinDists\Win_7_x64\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
bcdedit /store <_>:\boot\bcd /set {e5f9b9b7-3bb1-11e6-839b-d850e607fea0} osdevice ramdisk=[boot]\WinDists\Win_7_x64\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}

bcdedit /store <_>:\boot\bcd /copy {Default} /d "Windows 8.1 (32-bit) Setup"
    {cda5bc88-3bb4-11e6-839b-d850e607fea0}.

bcdedit /store <_>:\boot\bcd /set {cda5bc88-3bb4-11e6-839b-d850e607fea0} device ramdisk=[boot]\WinDists\Win_8.1_ia32\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
bcdedit /store <_>:\boot\bcd /set {cda5bc88-3bb4-11e6-839b-d850e607fea0} osdevice ramdisk=[boot]\WinDists\Win_8.1_ia32\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}

bcdedit /store <_>:\boot\bcd /copy {Default} /d "Windows 8.1 (64-bit) Setup"
    {330e8636-3bb5-11e6-839b-d850e607fea0}.

bcdedit /store <_>:\boot\bcd /set {330e8636-3bb5-11e6-839b-d850e607fea0} device ramdisk=[boot]\WinDists\Win_8.1_x64\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
bcdedit /store <_>:\boot\bcd /set {330e8636-3bb5-11e6-839b-d850e607fea0} osdevice ramdisk=[boot]\WinDists\Win_8.1_x64\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}

bcdedit /store <_>:\boot\bcd /copy {Default} /d "Windows 10 (32-bit) Setup"
    {87c0826c-3bb5-11e6-839b-d850e607fea0}.

bcdedit /store <_>:\boot\bcd /set {87c0826c-3bb5-11e6-839b-d850e607fea0} device ramdisk=[boot]\WinDists\Win_10_ia32\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
bcdedit /store <_>:\boot\bcd /set {87c0826c-3bb5-11e6-839b-d850e607fea0} osdevice ramdisk=[boot]\WinDists\Win_10_ia32\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}

bcdedit /store <_>:\boot\bcd /copy {Default} /d "Windows 10 (64-bit) Setup"
    {dd7288b2-3bb8-11e6-839b-d850e607fea0}.

bcdedit /store <_>:\boot\bcd /set {dd7288b2-3bb8-11e6-839b-d850e607fea0} device ramdisk=[boot]\WinDists\Win_10_x64\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
bcdedit /store <_>:\boot\bcd /set {dd7288b2-3bb8-11e6-839b-d850e607fea0} osdevice ramdisk=[boot]\WinDists\Win_10_x64\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}

bcdedit /store <_>:\boot\bcd /copy {Default} /d "Other Windows Setup (from \sources)"
The entry was successfully copied to {c9ff9b3a-3c53-11e6-839c-d850e607fea0}.

 


BCD

, -:
bcdedit /store <_>:\boot\bcd /delete {default}


 


BCD UEFI


UEFI, (, BootMgFw.efi).


, BCD.
..
bcdedit /store <_>:\boot\bcd

bcdedit /store <_>:\efi\microsoft\boot\bcd.


你不能随便拿. \boot\bcd \efi\microsoft\boot\bcd! path , {memdiag}.


\windows\system32\boot\winload.exe vs \windows\system32\boot\winload.efi
\boot\memtest.exe vs \efi\microsoft\boot\memtest.efi

Update
UEFI 64- Windows NT 6.0+, 32-Windows 8+.
, , Windows 8, IsolatedContext Yes. , (.. , , Windows 7 x64 UEFI).


 


Windows PE


, , Windows. , Windows PE.


 



. , - , :


没有来源错误


? , install.wim install.esd sources . Windows 10 x64\sources x86\sources . — .
, , , .


 



Windows , . .
 



  • . , .
    Microsoft-Windows-Setup | ImageInstall | OSImage | InstallFrom | Path.
    :
    setup.exe /unattend:< >
    .
    . . , . . — . . — .
     

  • cmd.exe. , :
    X:\sources\setup.exe /installFrom:< install.wim install.esd>
    . ISO.
    .
     

  • X: ( boot.wim), ! install.wim install.esd. ( )!
    , , Win 10 x64 :
    < >:\WinDists\Win_10_x64\setup.exe
    . - X:\sources, . , boot.wim. ! , ( ) ( setup.exe) 6- .

 



, , ? . , .


 



Windows PE, , , .
HKLM\SYSTEM\Setup\CmdLine , WinPE. winpeshl.exe. , :


  1. ( WallpaperHost.exe)
  2. , winpeshl.ini. — .
  3. PNP
  4. winpeshl.ini( ):
    • X:$Windows.~BT\sources\setup.exe
    • X:\setup.exe
    • X:\windows\system32\cmd.exe /k startnet.cmd

, . , :


  • winpeshl.ini cmd.exe
  • / X:\setup.exe startnet.cmd

( , ).
 



boot.wim

Windows 10 x64.
, X:, boot.wim. :
 


dism /get-wimInfo /wimFile:<_>:\WinDists\Win_10_x64\boot.wim

C DISM
: 6.3.9600.17031

   : <_>:\WinDists\Win_10_x64\boot.wim

: 1
 : Microsoft Windows PE (x64)
 : Microsoft Windows PE (x64)
 (): 1 357 917 901

: 2
 : Microsoft Windows Setup (x64)
 : Microsoft Windows Setup (x64)
 (): 1 540 370 231

  .

Windows PE, — Windows Setup. .. — 2.
, . C:\mnt.
 


dism /mount-wim /wimFile:<_>:\WinDists\Win_10_x64\boot.wim /index:2 /mountDir:C:\mnt

C DISM
: 6.3.9600.17031

 
[==========================100.0%==========================]
  .

, , C:\mnt\Windows\System32\ winpeshl.ini ( runsetup.cmd).
 


winpeshl.ini
[LaunchApps]
cmd.exe, "/k runsetup.cmd"

runsetup.cmd
@echo off
Title TishSerg Windows Setup Bootstrapper v1.0
color 9f

ver
echo.
echo [%time%] Initializing Windows PE...
Wpeinit

echo.
Wpeutil UpdateBootInfo > nul
for /f "tokens=3" %%a in (
    'reg query "HKLM\System\CurrentControlSet\Control" /v PEBootRamdiskSourceDrive'
) do set RamdiskSourceDrive=%%a
echo [%time%] Detected setup media: %RamdiskSourceDrive%

echo.
:: Windows dist path Affix
set WinDistAfx=WinDists\Win

:: Find Windows arch Affix
if "%PROCESSOR_ARCHITECTURE%" == "x86" (
    set WinArchAfx=ia32
) else (
    set WinArchAfx=x64
)

:: Find Windows version Affix
for /f "tokens=3" %%b in (
    'reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuildNumber'
) do set /a CurrentBuildNumber=%%b
if %CurrentBuildNumber% lss 6100 (
    :: Build < 6100 is Vista
    set WinVerAfx=Vista
    echo [%time%] Determined version of Windows: Vista (build %CurrentBuildNumber%^) %PROCESSOR_ARCHITECTURE%
) else if %CurrentBuildNumber% lss 7700 (
    :: Build < 7700 is 7
    set WinVerAfx=7
    echo [%time%] Determined version of Windows: 7 (build %CurrentBuildNumber%^) %PROCESSOR_ARCHITECTURE%
) else if %CurrentBuildNumber% lss 9300 (
    :: Build < 9300 is 8
    set WinVerAfx=8
    echo [%time%] Determined version of Windows: 8 (build %CurrentBuildNumber%^) %PROCESSOR_ARCHITECTURE%
) else if %CurrentBuildNumber% lss 9700 (
    :: Build < 9700 is 8.1
    set WinVerAfx=8.1
    echo [%time%] Determined version of Windows: 8.1 (build %CurrentBuildNumber%^) %PROCESSOR_ARCHITECTURE%
) else (
    :: Build > 9700 is 10
    set WinVerAfx=10
    echo [%time%] Determined version of Windows: 10 (build %CurrentBuildNumber%^) %PROCESSOR_ARCHITECTURE%
)

echo.
echo [%time%] Launching Windows Setup (%RamdiskSourceDrive%\%WinDistAfx%_%WinVerAfx%_%WinArchAfx%\setup.exe^)
%RamdiskSourceDrive%\%WinDistAfx%_%WinVerAfx%_%WinArchAfx%\setup.exe

:: When closed Windows Setup
color 2e
echo.
echo [%time%] Windows Setup closed
echo WScript.Quit MsgBox("You have closed Windows Setup."+vbCrlf+"Run 'System restore' instead? Or reboot?"+vbCrlf+vbCrlf+"Yes - Run 'System restore'"+vbCrlf+"No - Reboot"+vbCrlf+"Cancel - 'Just give me a Command line!'", vbQuestion+vbYesNoCancel, "Setup cancelled") > msgdlg.vbs
cscript msgdlg.vbs > nul
if %errorLevel% == 6 (
    echo [%time%] Here is Task Manager for you :^)
    start taskmgr
    echo [%time%] Run 'System restore' (%SystemDrive%\Sources\recovery\RecEnv.exe^)
    %SystemDrive%\Sources\recovery\RecEnv.exe
) else if %errorLevel% == 7 (
    echo [%time%] Will reboot now...
    Wpeutil Reboot
)

`runsetup.cmd`?

, winpeshl.ini runsetup.cmd Windows NT 6.0+. .. Win7, Win8 .. .


, .. - \sources\setup.exe X:\setup.exe :
image


, Windows . ISO X:\setup.exe .


! runsetup.cmd <_>:\\<_____>_<>_<>\setup.exe
( %RamdiskSourceDrive%\%WinDistAfx%_%WinVerAfx%_%WinArchAfx%\setup.exe). .. ( , ) :


  • D:\WinDists\Win_7_ia32\setup.exe
  • D:\WinDists\Win_10_x64\setup.exe

— .


:
 


dism /unmount-wim /mountDir:C:\mnt /commit

C DISM
: 6.3.9600.17031

 : <_>:\WinDists\Win_10_x64\boot.wim
 : 2
 
[==========================100.0%==========================]
 
[==========================100.0%==========================]
  .

! boot.wim. , Windows!


 


?


.


 


Windows


ei.cfg


`ei.cfg`

[Channel]
Retail


setup.exe. , ramdisk- (boot.wim), ei.cfg . (+1 , ramdisk- /installFrom).


 


Windows


`Grub4Dos`
bcdedit /store <_>:\boot\bcd /create /d "Grub4Dos Menu" /application BootSector
 {b3923807-3ebb-11e6-83a0-d850e607fea0}  .

bcdedit /store <_>:\boot\bcd /set {b3923807-3ebb-11e6-83a0-d850e607fea0} device boot
bcdedit /store <_>:\boot\bcd /set {b3923807-3ebb-11e6-83a0-d850e607fea0} path \grldr

bcdedit /store <_>:\boot\bcd /DisplayOrder {b3923807-3ebb-11e6-83a0-d850e607fea0} /AddFirst

. : BOOTMGR GRLDR.


 


boot.wim ramdisk


BootMgr boot.wim ramdisk . .. Windows , . , . WinPE .
 


bcdedit /store <_>:\boot\bcd /set {<GUID   Windows>} BootMenuPolicy Legacy

, ( , ), (^̮^)


 



. Windows 7 . Windows 8+ - ( ).
 


bcdedit /store <_>:\boot\bcd /set {<GUID   Windows>} Sos True

Windows 7. — .


 



, :


  1. Windows ( ISO-)
  2. 使用Windows分发文件([sources]每个ISO映像的内容)创建了文件夹结构
  3. 设置Windows启动管理器菜单
  4. 我们向boot.wim每个发行版添加了两个文件。

仅此而已。欢迎提出问题,意见和建议(ʘ‿ʘ)

Source: https://habr.com/ru/post/zh-CN395629/


All Articles