From bdb8eb809217dff1237426d76df56ad49cbae772 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Wed, 22 Apr 2026 18:21:07 +0200 Subject: [PATCH] download required oscdimg.exe as first step else it could happen that after hours of work the entire process fails if no internet connection is available at that moment. also keep the local copy, once downloaded. --- tiny11maker.ps1 | 69 +++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/tiny11maker.ps1 b/tiny11maker.ps1 index c24757f..f7c7a07 100644 --- a/tiny11maker.ps1 +++ b/tiny11maker.ps1 @@ -107,6 +107,36 @@ $Host.UI.RawUI.WindowTitle = "Tiny11 image creator" Clear-Host Write-Output "Welcome to the tiny11 image creator! Release: 09-07-25" +# Download/check the oscdimg tool first, so the build doesn't fail after hours of work +# if no internet is available at that moment. +Write-Output "Checking for prerequisite oscdimg.exe..." +$ADKDepTools = "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg" +$localOSCDIMGPath = "$PSScriptRoot\oscdimg.exe" + +if ([System.IO.Directory]::Exists($ADKDepTools)) { + Write-Output "Will be using oscdimg.exe from system ADK." + $OSCDIMG = "$ADKDepTools\oscdimg.exe" +} else { + Write-Output "ADK folder not found. Creating/Using local copy of oscdimg.exe." + $url = "https://msdl.microsoft.com/download/symbols/oscdimg.exe/3D44737265000/oscdimg.exe" + + if (-not (Test-Path -Path $localOSCDIMGPath)) { + Write-Output "Downloading oscdimg.exe..." + Invoke-WebRequest -Uri $url -OutFile $localOSCDIMGPath + + if (Test-Path $localOSCDIMGPath) { + Write-Output "oscdimg.exe downloaded successfully." + } else { + Write-Error "Failed to download oscdimg.exe." + exit 1 + } + } else { + Write-Output "oscdimg.exe already exists locally." + } + + $OSCDIMG = $localOSCDIMGPath +} + $hostArchitecture = $Env:PROCESSOR_ARCHITECTURE New-Item -ItemType Directory -Force -Path "$ScratchDisk\tiny11\sources" | Out-Null do { @@ -439,32 +469,6 @@ Write-Output "The tiny11 image is now completed. Proceeding with the making of t Write-Output "Copying unattended file for bypassing MS account on OOBE..." Copy-Item -Path "$PSScriptRoot\autounattend.xml" -Destination "$ScratchDisk\tiny11\autounattend.xml" -Force | Out-Null Write-Output "Creating ISO image..." -$ADKDepTools = "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg" -$localOSCDIMGPath = "$PSScriptRoot\oscdimg.exe" - -if ([System.IO.Directory]::Exists($ADKDepTools)) { - Write-Output "Will be using oscdimg.exe from system ADK." - $OSCDIMG = "$ADKDepTools\oscdimg.exe" -} else { - Write-Output "ADK folder not found. Will be using bundled oscdimg.exe." - $url = "https://msdl.microsoft.com/download/symbols/oscdimg.exe/3D44737265000/oscdimg.exe" - - if (-not (Test-Path -Path $localOSCDIMGPath)) { - Write-Output "Downloading oscdimg.exe..." - Invoke-WebRequest -Uri $url -OutFile $localOSCDIMGPath - - if (Test-Path $localOSCDIMGPath) { - Write-Output "oscdimg.exe downloaded successfully." - } else { - Write-Error "Failed to download oscdimg.exe." - exit 1 - } - } else { - Write-Output "oscdimg.exe already exists locally." - } - - $OSCDIMG = $localOSCDIMGPath -} & "$OSCDIMG" '-m' '-o' '-u2' '-udfver102' "-bootdata:2#p0,e,b$ScratchDisk\tiny11\boot\etfsboot.com#pEF,e,b$ScratchDisk\tiny11\efi\microsoft\boot\efisys.bin" "$ScratchDisk\tiny11" "$PSScriptRoot\tiny11.iso" @@ -477,8 +481,6 @@ Remove-Item -Path "$ScratchDisk\scratchdir" -Recurse -Force | Out-Null Write-Output "Ejecting Iso drive" Get-Volume -DriveLetter $DriveLetter[0] | Get-DiskImage | Dismount-DiskImage Write-Output "Iso drive ejected" -Write-Output "Removing oscdimg.exe..." -Remove-Item -Path "$PSScriptRoot\oscdimg.exe" -Force -ErrorAction SilentlyContinue Write-Output "Removing autounattend.xml..." Remove-Item -Path "$PSScriptRoot\autounattend.xml" -Force -ErrorAction SilentlyContinue @@ -505,17 +507,6 @@ if (Test-Path -Path "$ScratchDisk\scratchdir") { } else { Write-Output "scratchdir folder does not exist. No action needed." } -if (Test-Path -Path "$PSScriptRoot\oscdimg.exe") { - Write-Output "oscdimg.exe still exists. Attempting to remove it again..." - Remove-Item -Path "$PSScriptRoot\oscdimg.exe" -Force -ErrorAction SilentlyContinue - if (Test-Path -Path "$PSScriptRoot\oscdimg.exe") { - Write-Output "Failed to remove oscdimg.exe." - } else { - Write-Output "oscdimg.exe removed successfully." - } -} else { - Write-Output "oscdimg.exe does not exist. No action needed." -} if (Test-Path -Path "$PSScriptRoot\autounattend.xml") { Write-Output "autounattend.xml still exists. Attempting to remove it again..." Remove-Item -Path "$PSScriptRoot\autounattend.xml" -Force -ErrorAction SilentlyContinue