Fixed Ventoy drive copy typo and began conversion of DISM commands into DISM cmdlets (#1727)

* Fixed Ventoy drive copy typo

* DISM cmdlet Update (Part 1)

Began replacing basic DISM commands with cmdlets from the DISM module.

This change only affects the mount, unmount, and export operations. All other operations still use DISM

---------

Co-authored-by: Chris Titus <contact@christitus.com>
This commit is contained in:
CodingWonders 2024-03-28 16:50:49 +01:00 committed by GitHub
parent bc089a8ad5
commit 70f3ed541f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 12598 deletions

View File

@ -195,7 +195,7 @@ function Copy-ToUSB([string] $fileToCopy)
Write-Progress -Activity "Copying File" -Status "Progress" -PercentComplete $completed -CurrentOperation ("{0:N2} MB / {1:N2} MB" -f ($_.BytesTransferred / 1MB), ($totalSize / 1MB)) Write-Progress -Activity "Copying File" -Status "Progress" -PercentComplete $completed -CurrentOperation ("{0:N2} MB / {1:N2} MB" -f ($_.BytesTransferred / 1MB), ($totalSize / 1MB))
} }
Write-Host "File copied to Ventoy drive $($volume.DriveLette)" Write-Host "File copied to Ventoy drive $($volume.DriveLetter)"
return return
} }
} }

View File

@ -100,8 +100,16 @@ public class PowerManagement {
try { try {
Write-Host "Mounting Windows image. This may take a while." Write-Host "Mounting Windows image. This may take a while."
dism /mount-image /imagefile:$mountDir\sources\install.wim /index:$index /mountdir:$scratchDir Mount-WindowsImage -ImagePath "$mountDir\sources\install.wim" -Index $index -Path "$scratchDir"
Write-Host "Mounting complete! Performing removal of applications..." if ($?)
{
Write-Host "Mounting complete! Performing removal of applications..."
}
else
{
Write-Host "Could not mount image. Exiting..."
return
}
if ($injectDrivers) if ($injectDrivers)
{ {
@ -299,13 +307,13 @@ public class PowerManagement {
Write-Host "Cleanup complete." Write-Host "Cleanup complete."
Write-Host "Unmounting image..." Write-Host "Unmounting image..."
dism /unmount-image /mountdir:$scratchDir /commit Dismount-WindowsImage -Path $scratchDir -Save
} }
try { try {
Write-Host "Exporting image into $mountDir\sources\install2.wim" Write-Host "Exporting image into $mountDir\sources\install2.wim"
dism /Export-Image /SourceImageFile:"$mountDir\sources\install.wim" /SourceIndex:$index /DestinationImageFile:"$mountDir\sources\install2.wim" /compress:max Export-WindowsImage -SourceImagePath "$mountDir\sources\install.wim" -SourceIndex $index -DestinationImagePath "$mountDir\sources\install2.wim" -CompressionType "Max"
Write-Host "Remove old '$mountDir\sources\install.wim' and rename $mountDir\sources\install2.wim" Write-Host "Remove old '$mountDir\sources\install.wim' and rename $mountDir\sources\install2.wim"
Remove-Item "$mountDir\sources\install.wim" Remove-Item "$mountDir\sources\install.wim"
Rename-Item "$mountDir\sources\install2.wim" "$mountDir\sources\install.wim" Rename-Item "$mountDir\sources\install2.wim" "$mountDir\sources\install.wim"
@ -319,7 +327,7 @@ public class PowerManagement {
# Next step boot image # Next step boot image
Write-Host "Mounting boot image $mountDir\sources\boot.wim into $scratchDir" Write-Host "Mounting boot image $mountDir\sources\boot.wim into $scratchDir"
dism /mount-image /imagefile:"$mountDir\sources\boot.wim" /index:2 /mountdir:"$scratchDir" Mount-WindowsImage -ImagePath "$mountDir\sources\boot.wim" -Index 2 -Path "$scratchDir"
if ($injectDrivers) if ($injectDrivers)
{ {
@ -365,7 +373,7 @@ public class PowerManagement {
reg unload HKLM\zSYSTEM reg unload HKLM\zSYSTEM
Write-Host "Unmounting image..." Write-Host "Unmounting image..."
dism /unmount-image /mountdir:$scratchDir /commit Dismount-WindowsImage -Path $scratchDir -Save
Write-Host "Creating ISO image" Write-Host "Creating ISO image"

12591
winutil.ps1

File diff suppressed because it is too large Load Diff