mirror of
https://github.com/ntdevlabs/tiny11builder.git
synced 2024-11-24 12:55:29 +00:00
Merge a5a4d97994
into 233b6b0fc4
This commit is contained in:
commit
7ddac0ae17
@ -49,11 +49,11 @@ $DriveLetter = $DriveLetter + ":"
|
||||
if ((Test-Path "$DriveLetter\sources\boot.wim") -eq $false -or (Test-Path "$DriveLetter\sources\install.wim") -eq $false) {
|
||||
if ((Test-Path "$DriveLetter\sources\install.esd") -eq $true) {
|
||||
Write-Host "Found install.esd, converting to install.wim..."
|
||||
& 'dism' '/English' "/Get-WimInfo" "/wimfile:$DriveLetter\sources\install.esd"
|
||||
Get-WindowsImage -ImagePath $DriveLetter\sources\install.esd
|
||||
$index = Read-Host "Please enter the image index"
|
||||
Write-Host ' '
|
||||
Write-Host 'Converting install.esd to install.wim. This may take a while...'
|
||||
& 'DISM' /Export-Image /SourceImageFile:"$DriveLetter\sources\install.esd" /SourceIndex:$index /DestinationImageFile:"$ScratchDisk\tiny11\sources\install.wim" /Compress:max /CheckIntegrity
|
||||
Export-WindowsImage -SourceImagePath $DriveLetter\sources\install.esd -SourceIndex $index -DestinationImagePath $ScratchDisk\tiny11\sources\install.wim -Compressiontype Maximum -CheckIntegrity
|
||||
} else {
|
||||
Write-Host "Can't find Windows OS Installation files in the specified Drive Letter.."
|
||||
Write-Host "Please enter the correct DVD Drive Letter.."
|
||||
@ -69,10 +69,10 @@ Write-Host "Copy complete!"
|
||||
Start-Sleep -Seconds 2
|
||||
Clear-Host
|
||||
Write-Host "Getting image information:"
|
||||
& 'dism' '/English' "/Get-WimInfo" "/wimfile:$ScratchDisk\tiny11\sources\install.wim"
|
||||
Get-WindowsImage -ImagePath $ScratchDisk\tiny11\sources\install.wim
|
||||
$index = Read-Host "Please enter the image index"
|
||||
Write-Host "Mounting Windows image. This may take a while."
|
||||
$wimFilePath = "$($env:SystemDrive)\tiny11\sources\install.wim"
|
||||
$wimFilePath = "$($env:SystemDrive)\tiny11\sources\install.wim"
|
||||
& takeown "/F" $wimFilePath
|
||||
& icacls $wimFilePath "/grant" "$($adminGroup.Value):(F)"
|
||||
try {
|
||||
@ -81,7 +81,7 @@ try {
|
||||
# This block will catch the error and suppress it.
|
||||
}
|
||||
New-Item -ItemType Directory -Force -Path "$ScratchDisk\scratchdir" > $null
|
||||
& dism /English "/mount-image" "/imagefile:$($env:SystemDrive)\tiny11\sources\install.wim" "/index:$index" "/mountdir:$($env:SystemDrive)\scratchdir"
|
||||
Mount-WindowsImage -ImagePath $($env:SystemDrive)\tiny11\sources\install.wim -Index $index -ScratchDirectory $($env:SystemDrive)\scratchdir
|
||||
|
||||
$imageIntl = & dism /English /Get-Intl "/Image:$($env:SystemDrive)\scratchdir"
|
||||
$languageLine = $imageIntl -split '\n' | Where-Object { $_ -match 'Default system UI language : ([a-zA-Z]{2}-[a-zA-Z]{2})' }
|
||||
@ -358,13 +358,14 @@ reg unload HKLM\zSCHEMA >null
|
||||
reg unload HKLM\zSOFTWARE
|
||||
reg unload HKLM\zSYSTEM >null
|
||||
Write-Host "Cleaning up image..."
|
||||
& 'dism' '/English' "/image:$ScratchDisk\scratchdir" '/Cleanup-Image' '/StartComponentCleanup' '/ResetBase' >null
|
||||
Repair-WindowsImage -ScratchDirectory $ScratchDisk\scratchdir -StartComponentCleanup -ResetBase
|
||||
Write-Host "Cleanup complete."
|
||||
Write-Host ' '
|
||||
Write-Host "Unmounting image..."
|
||||
& 'dism' '/English' '/unmount-image' "/mountdir:$ScratchDisk\scratchdir" '/commit'
|
||||
Dismount-WindowsImage -ScratchDirectory $ScratchDisk\scratchdir -Save
|
||||
Write-Host "Exporting image..."
|
||||
& 'dism' '/English' '/Export-Image' "/SourceImageFile:$ScratchDisk\tiny11\sources\install.wim" "/SourceIndex:$index" "/DestinationImageFile:$ScratchDisk\tiny11\sources\install2.wim" '/compress:recovery'
|
||||
# Compressiontype Recovery is not supported with PShell https://learn.microsoft.com/en-us/powershell/module/dism/export-windowsimage?view=windowsserver2022-ps#-compressiontype
|
||||
Export-WindowsImage -SourceImagePath $ScratchDisk\tiny11\sources\install.wim -SourceIndex $index -DestinationImagePath $ScratchDisk\tiny11\sources\install2.wim -CompressionType Fast
|
||||
Remove-Item -Path "$ScratchDisk\tiny11\sources\install.wim" -Force >null
|
||||
Rename-Item -Path "$ScratchDisk\tiny11\sources\install2.wim" -NewName "install.wim" >null
|
||||
Write-Host "Windows image completed. Continuing with boot.wim."
|
||||
@ -375,7 +376,7 @@ $wimFilePath = "$($env:SystemDrive)\tiny11\sources\boot.wim"
|
||||
& takeown "/F" $wimFilePath >null
|
||||
& icacls $wimFilePath "/grant" "$($adminGroup.Value):(F)"
|
||||
Set-ItemProperty -Path $wimFilePath -Name IsReadOnly -Value $false
|
||||
& 'dism' '/English' '/mount-image' "/imagefile:$ScratchDisk\tiny11\sources\boot.wim" '/index:2' "/mountdir:$ScratchDisk\scratchdir"
|
||||
Mount-WindowsImage -ImagePath $ScratchDisk\tiny11\sources\boot.wim -Index 2 -ScratchDirectory $ScratchDisk\scratchdir
|
||||
Write-Host "Loading registry..."
|
||||
reg load HKLM\zCOMPONENTS $ScratchDisk\scratchdir\Windows\System32\config\COMPONENTS
|
||||
reg load HKLM\zDEFAULT $ScratchDisk\scratchdir\Windows\System32\config\default
|
||||
@ -405,7 +406,7 @@ $regKey.Close()
|
||||
reg unload HKLM\zSOFTWARE
|
||||
reg unload HKLM\zSYSTEM >null
|
||||
Write-Host "Unmounting image..."
|
||||
& 'dism' '/English' '/unmount-image' "/mountdir:$ScratchDisk\scratchdir" '/commit'
|
||||
Dismount-WindowsImage -ScratchDirectory $ScratchDisk\scratchdir -Save
|
||||
Clear-Host
|
||||
Write-Host "The tiny11 image is now completed. Proceeding with the making of the ISO..."
|
||||
Write-Host "Copying unattended file for bypassing MS account on OOBE..."
|
||||
|
Loading…
Reference in New Issue
Block a user