diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..039b241 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +tiny11.log +.vs +.vscode \ No newline at end of file diff --git a/oscdimg.exe b/oscdimg.exe new file mode 100644 index 0000000..334d9c8 Binary files /dev/null and b/oscdimg.exe differ diff --git a/tiny11maker.ps1 b/tiny11maker.ps1 index caba846..57fd979 100644 --- a/tiny11maker.ps1 +++ b/tiny11maker.ps1 @@ -43,17 +43,22 @@ Write-Host "Welcome to the tiny11 image creator! Release: 05-06-24" $hostArchitecture = $Env:PROCESSOR_ARCHITECTURE New-Item -ItemType Directory -Force -Path "$ScratchDisk\tiny11\sources" >null -$DriveLetter = Read-Host "Please enter the drive letter for the Windows 11 image" -$DriveLetter = $DriveLetter + ":" +$ImagePath = Read-Host "Paste the image path (without quotes) here" +$DriveLetter = Mount-DiskImage -ImagePath "$ImagePath" | Get-Volume | Select-Object -ExpandProperty 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) { +if (-not $DriveLetter) { + Write-Host "Path not specified or wrong." + exit +} + +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" + & 'dism' '/English' "/Get-WimInfo" "/wimfile:${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 + & 'DISM' /Export-Image /SourceImageFile:"${DriveLetter}:\sources\install.esd" /SourceIndex:$index /DestinationImageFile:"$ScratchDisk\tiny11\sources\install.wim" /Compress:max /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.." @@ -62,7 +67,7 @@ if ((Test-Path "$DriveLetter\sources\boot.wim") -eq $false -or (Test-Path "$Driv } Write-Host "Copying Windows image..." -Copy-Item -Path "$DriveLetter\*" -Destination "$ScratchDisk\tiny11" -Recurse -Force > null +Copy-Item -Path "${DriveLetter}:\*" -Destination "$ScratchDisk\tiny11" -Recurse -Force > null Set-ItemProperty -Path "$ScratchDisk\tiny11\sources\install.esd" -Name IsReadOnly -Value $false > $null 2>&1 Remove-Item "$ScratchDisk\tiny11\sources\install.esd" > $null 2>&1 Write-Host "Copy complete!" @@ -440,7 +445,8 @@ if ([System.IO.Directory]::Exists($ADKDepTools)) { & "$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" # Finishing up -Write-Host "Creation completed! Press any key to exit the script..." +Write-Host "Creation completed! Unmounting image..." +Dismount-DiskImage -ImagePath "$ImagePath" Read-Host "Press Enter to continue" Write-Host "Performing Cleanup..." Remove-Item -Path "$ScratchDisk\tiny11" -Recurse -Force >null