From a45402e9d86794bcd636ee84c10d112f5c3d0854 Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Fri, 22 Nov 2024 18:24:00 +0100 Subject: [PATCH 01/10] Set Boot Manager entry timeout to 0 Fixes #2562 --- functions/microwin/Microwin-NewFirstRun.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/functions/microwin/Microwin-NewFirstRun.ps1 b/functions/microwin/Microwin-NewFirstRun.ps1 index 614df6bc..d6e5d4b7 100644 --- a/functions/microwin/Microwin-NewFirstRun.ps1 +++ b/functions/microwin/Microwin-NewFirstRun.ps1 @@ -63,6 +63,22 @@ function Microwin-NewFirstRun { { } + + # Get BCD entries and set bootmgr timeout accordingly + try + { + # Check if the number of occurrences of "path" is 2 - this fixes the Boot Manager screen issue (#2562) + if ((bcdedit | Select-String "path").Count -eq 2) + { + # Set bootmgr timeout to 0 + bcdedit /set `{bootmgr`} timeout 0 + } + } + catch + { + + } + '@ $firstRun | Out-File -FilePath "$env:temp\FirstStartup.ps1" -Force } From 9dcf8dd50e20b522f71039114882bf50567dee47 Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Sun, 24 Nov 2024 12:51:53 +0100 Subject: [PATCH 02/10] Exclude Windows Hello stuff from package removal --- functions/microwin/Microwin-RemovePackages.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/functions/microwin/Microwin-RemovePackages.ps1 b/functions/microwin/Microwin-RemovePackages.ps1 index ed53056c..2f84451e 100644 --- a/functions/microwin/Microwin-RemovePackages.ps1 +++ b/functions/microwin/Microwin-RemovePackages.ps1 @@ -45,7 +45,8 @@ function Microwin-RemovePackages { $_ -NotLike "*Foundation*" -AND $_ -NotLike "*LanguageFeatures*" -AND $_ -NotLike "*VBSCRIPT*" -AND - $_ -NotLike "*License*" + $_ -NotLike "*License*" -AND + $_ -NotLike "*HelloFace*" } $failedCount = 0 From 706f65f6316bac8fa68f9a7e2fcdb8a81e1ba219 Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Sun, 24 Nov 2024 12:52:59 +0100 Subject: [PATCH 03/10] Obscure passwords with Base64 and fix indentation Fixes #3064 --- functions/microwin/Microwin-NewUnattend.ps1 | 37 +++++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/functions/microwin/Microwin-NewUnattend.ps1 b/functions/microwin/Microwin-NewUnattend.ps1 index 87188aca..c270c51d 100644 --- a/functions/microwin/Microwin-NewUnattend.ps1 +++ b/functions/microwin/Microwin-NewUnattend.ps1 @@ -31,7 +31,7 @@ function Microwin-NewUnattend { Administrators PW-REPLACEME - true</PlainText> + <PlainText>PT-STATUS</PlainText> </Password> </LocalAccount> </LocalAccounts> @@ -42,7 +42,7 @@ function Microwin-NewUnattend { <LogonCount>1</LogonCount> <Password> <Value>PW-REPLACEME</Value> - <PlainText>true</PlainText> + <PlainText>PT-STATUS</PlainText> </Password> </AutoLogon> <OOBE> @@ -295,15 +295,38 @@ function Microwin-NewUnattend { </settings> '@ if ((Microwin-TestCompatibleImage $imgVersion $([System.Version]::new(10,0,22000,1))) -eq $false) { - # Replace the placeholder text with an empty string to make it valid for Windows 10 Setup - $unattend = $unattend.Replace("<#REPLACEME#>", "").Trim() + # Replace the placeholder text with an empty string to make it valid for Windows 10 Setup + $unattend = $unattend.Replace("<#REPLACEME#>", "").Trim() } else { - # Replace the placeholder text with the Specialize pass - $unattend = $unattend.Replace("<#REPLACEME#>", $specPass).Trim() + # Replace the placeholder text with the Specialize pass + $unattend = $unattend.Replace("<#REPLACEME#>", $specPass).Trim() } + + # User password in Base64. According to Microsoft, this is the way you can hide this sensitive information. + # More information can be found here: https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/wsim/hide-sensitive-data-in-an-answer-file + # Yeah, I know this is not the best way to protect this kind of data, but we all know how Microsoft is - a cheese grater without holes in terms of security + $b64pass = "" + # Replace default User and Password values with the provided parameters $unattend = $unattend.Replace("USER-REPLACEME", $userName).Trim() - $unattend = $unattend.Replace("PW-REPLACEME", $userPassword).Trim() + try { + # I want to play it safe here - I don't want encoding mismatch problems like last time + + # NOTE: "Password" needs to be appended to the password specified by the user. Otherwise, a parse error will occur when processing oobeSystem. + # This will not be added to the actual password stored in the target system's SAM file - only the provided password + $b64pass = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes("$($userPassword)Password")) + } catch { + $b64pass = "" + } + if ($b64pass -ne "") { + # If we could encode the password with Base64, put it in the answer file and indicate that it's NOT in plain text + $unattend = $unattend.Replace("PW-REPLACEME", $b64pass).Trim() + $unattend = $unattend.Replace("PT-STATUS", "false").Trim() + $b64pass = "" + } else { + $unattend = $unattend.Replace("PW-REPLACEME", $userPassword).Trim() + $unattend = $unattend.Replace("PT-STATUS", "true").Trim() + } # Save unattended answer file with UTF-8 encoding $unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force -Encoding utf8 From c5968243eb16a39f28ece512971561cc8425b601 Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Sun, 24 Nov 2024 13:37:06 +0100 Subject: [PATCH 04/10] Fix name of excluded package --- functions/microwin/Microwin-RemovePackages.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/microwin/Microwin-RemovePackages.ps1 b/functions/microwin/Microwin-RemovePackages.ps1 index 2f84451e..470d4df4 100644 --- a/functions/microwin/Microwin-RemovePackages.ps1 +++ b/functions/microwin/Microwin-RemovePackages.ps1 @@ -46,7 +46,7 @@ function Microwin-RemovePackages { $_ -NotLike "*LanguageFeatures*" -AND $_ -NotLike "*VBSCRIPT*" -AND $_ -NotLike "*License*" -AND - $_ -NotLike "*HelloFace*" + $_ -NotLike "*Hello-Face*" } $failedCount = 0 From 8e647e8c49db48cf3c1676e449c3469409a32c8d Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Sun, 24 Nov 2024 18:16:55 +0100 Subject: [PATCH 05/10] Update comment It reflects my feelings towards Microsoft when it comes to security a lot better --- functions/microwin/Microwin-NewUnattend.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/microwin/Microwin-NewUnattend.ps1 b/functions/microwin/Microwin-NewUnattend.ps1 index c270c51d..dda71bb3 100644 --- a/functions/microwin/Microwin-NewUnattend.ps1 +++ b/functions/microwin/Microwin-NewUnattend.ps1 @@ -304,7 +304,9 @@ function Microwin-NewUnattend { # User password in Base64. According to Microsoft, this is the way you can hide this sensitive information. # More information can be found here: https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/wsim/hide-sensitive-data-in-an-answer-file - # Yeah, I know this is not the best way to protect this kind of data, but we all know how Microsoft is - a cheese grater without holes in terms of security + # Yeah, I know this is not the best way to protect this kind of data, but we all know how Microsoft is - "the Apple of security" (in a sense, it takes them + # an eternity to implement basic security features right. Just look at the NTLM and Kerberos situation!) + $b64pass = "" # Replace default User and Password values with the provided parameters From cc7b3d7836cc3409665aa327e838207149e6a1be Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Sun, 1 Dec 2024 18:01:38 +0100 Subject: [PATCH 06/10] Remove jargon of scratch directory options --- xaml/inputXML.xaml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xaml/inputXML.xaml b/xaml/inputXML.xaml index db6894f4..2ec0a1de 100644 --- a/xaml/inputXML.xaml +++ b/xaml/inputXML.xaml @@ -1045,8 +1045,10 @@ Choose a Windows ISO file that you've downloaded <LineBreak/> Check the status in the console </TextBlock> + <Rectangle Fill="{DynamicResource MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/> + <TextBlock Margin="5" Padding="1" TextWrapping="Wrap" Foreground="{DynamicResource ComboBoxForegroundColor}" ToolTip="Scratch directories act as a custom destination for image files"><Bold>Scratch directory settings (optional)</Bold></TextBlock> <CheckBox x:Name="WPFMicrowinISOScratchDir" Content="Use ISO directory for ScratchDir " IsChecked="False" Margin="{DynamicResource MicrowinCheckBoxMargin}" - ToolTip="Use ISO directory for ScratchDir " /> + ToolTip="Check this to use the path of the ISO file you specify as a scratch directory" /> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <!-- Takes the remaining space --> @@ -1056,7 +1058,7 @@ Text="Scratch" Margin="2" IsReadOnly="False" - ToolTip="Alt Path For Scratch Directory" + ToolTip="Specify an alternate path for the scratch directory" Grid.Column="0" VerticalAlignment="Center" Foreground="{DynamicResource LabelboxForegroundColor}"> @@ -1072,6 +1074,7 @@ </Button.Content> </Button> </Grid> + <Rectangle Fill="{DynamicResource MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/> <TextBox Name="MicrowinFinalIsoLocation" Background="Transparent" BorderBrush="{DynamicResource MainForegroundColor}" Text="ISO location will be printed here" Margin="2" From 2c4cf504fcaf4c0829173d4c3a8be3fb4f1ee626 Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Sun, 1 Dec 2024 18:02:52 +0100 Subject: [PATCH 07/10] Package exclusion improvements - Removed AppX packages from OS package exclusion list - Added exclusion of PowerShell ISE (source: Discord server - yes, some people still use the PowerShell ISE) --- .../microwin/Microwin-RemovePackages.ps1 | 34 ++----------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/functions/microwin/Microwin-RemovePackages.ps1 b/functions/microwin/Microwin-RemovePackages.ps1 index 470d4df4..6901f2af 100644 --- a/functions/microwin/Microwin-RemovePackages.ps1 +++ b/functions/microwin/Microwin-RemovePackages.ps1 @@ -7,38 +7,9 @@ function Microwin-RemovePackages { $_ -NotLike "*indows-Client-LanguagePack*" -AND $_ -NotLike "*LanguageFeatures-Basic*" -AND $_ -NotLike "*Package_for_ServicingStack*" -AND - $_ -NotLike "*.NET*" -AND - $_ -NotLike "*Store*" -AND - $_ -NotLike "*VCLibs*" -AND - $_ -NotLike "*AAD.BrokerPlugin", - $_ -NotLike "*LockApp*" -AND + $_ -NotLike "*DotNet*" -AND $_ -NotLike "*Notepad*" -AND - $_ -NotLike "*immersivecontrolpanel*" -AND - $_ -NotLike "*ContentDeliveryManager*" -AND - $_ -NotLike "*PinningConfirMationDialog*" -AND - $_ -NotLike "*SecHealthUI*" -AND - $_ -NotLike "*SecureAssessmentBrowser*" -AND - $_ -NotLike "*PrintDialog*" -AND - $_ -NotLike "*AssignedAccessLockApp*" -AND - $_ -NotLike "*OOBENetworkConnectionFlow*" -AND - $_ -NotLike "*Apprep.ChxApp*" -AND - $_ -NotLike "*CBS*" -AND - $_ -NotLike "*OOBENetworkCaptivePortal*" -AND - $_ -NotLike "*PeopleExperienceHost*" -AND - $_ -NotLike "*ParentalControls*" -AND - $_ -NotLike "*Win32WebViewHost*" -AND - $_ -NotLike "*InputApp*" -AND - $_ -NotLike "*DirectPlay*" -AND - $_ -NotLike "*AccountsControl*" -AND - $_ -NotLike "*AsyncTextService*" -AND - $_ -NotLike "*CapturePicker*" -AND - $_ -NotLike "*CredDialogHost*" -AND - $_ -NotLike "*BioEnrollMent*" -AND - $_ -NotLike "*ShellExperienceHost*" -AND - $_ -NotLike "*DesktopAppInstaller*" -AND - $_ -NotLike "*WebMediaExtensions*" -AND $_ -NotLike "*WMIC*" -AND - $_ -NotLike "*UI.XaML*" -AND $_ -NotLike "*Ethernet*" -AND $_ -NotLike "*Wifi*" -AND $_ -NotLike "*FodMetadata*" -AND @@ -46,7 +17,8 @@ function Microwin-RemovePackages { $_ -NotLike "*LanguageFeatures*" -AND $_ -NotLike "*VBSCRIPT*" -AND $_ -NotLike "*License*" -AND - $_ -NotLike "*Hello-Face*" + $_ -NotLike "*Hello-Face*" -AND + $_ -NotLike "*ISE*" } $failedCount = 0 From 759d8f687872a7d4b28948d972abbd05766fbf6a Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Sun, 1 Dec 2024 18:03:32 +0100 Subject: [PATCH 08/10] Exclude Windows Photo Viewer from dir removal --- functions/microwin/Invoke-Microwin.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions/microwin/Invoke-Microwin.ps1 b/functions/microwin/Invoke-Microwin.ps1 index 65b032ab..077f4711 100644 --- a/functions/microwin/Invoke-Microwin.ps1 +++ b/functions/microwin/Invoke-Microwin.ps1 @@ -189,8 +189,6 @@ public class PowerManagement { Microwin-RemoveFileOrDirectory -pathToDelete "$($scratchDir)\Windows\DiagTrack" -Directory Microwin-RemoveFileOrDirectory -pathToDelete "$($scratchDir)\Windows\InboxApps" -Directory Microwin-RemoveFileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\LocationNotificationWindows.exe" - Microwin-RemoveFileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Windows Photo Viewer" -Directory - Microwin-RemoveFileOrDirectory -pathToDelete "$($scratchDir)\Program Files\Windows Photo Viewer" -Directory Microwin-RemoveFileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Windows Media Player" -Directory Microwin-RemoveFileOrDirectory -pathToDelete "$($scratchDir)\Program Files\Windows Media Player" -Directory Microwin-RemoveFileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Windows Mail" -Directory From 3cfc7c92b49994607768c045d93b921b8de5cf4a Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Mon, 2 Dec 2024 21:46:38 +0100 Subject: [PATCH 09/10] Improve copy operation to Ventoy drives This change may fix the issues where there's a conflict between both Ventoy's and MicroWin's unattended answer files, causing target images to stop working as expected during OOBE --- functions/microwin/Microwin-CopyToUSB.ps1 | 48 +++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/functions/microwin/Microwin-CopyToUSB.ps1 b/functions/microwin/Microwin-CopyToUSB.ps1 index 06f4219d..f1b37c95 100644 --- a/functions/microwin/Microwin-CopyToUSB.ps1 +++ b/functions/microwin/Microwin-CopyToUSB.ps1 @@ -16,6 +16,54 @@ function Microwin-CopyToUSB([string]$fileToCopy) { } Write-Host "File copied to Ventoy drive $($volume.DriveLetter)" + + # Detect if config files are present, move them if they are, and configure the Ventoy drive to not bypass the requirements + $customVentoyConfig = @' +{ + "control":[ + { "VTOY_WIN11_BYPASS_CHECK": "0" }, + { "VTOY_WIN11_BYPASS_NRO": "0" } + ], + "control_legacy":[ + { "VTOY_WIN11_BYPASS_CHECK": "0" }, + { "VTOY_WIN11_BYPASS_NRO": "0" } + ], + "control_uefi":[ + { "VTOY_WIN11_BYPASS_CHECK": "0" }, + { "VTOY_WIN11_BYPASS_NRO": "0" } + ], + "control_ia32":[ + { "VTOY_WIN11_BYPASS_CHECK": "0" }, + { "VTOY_WIN11_BYPASS_NRO": "0" } + ], + "control_aa64":[ + { "VTOY_WIN11_BYPASS_CHECK": "0" }, + { "VTOY_WIN11_BYPASS_NRO": "0" } + ], + "control_mips":[ + { "VTOY_WIN11_BYPASS_CHECK": "0" }, + { "VTOY_WIN11_BYPASS_NRO": "0" } + ] +} +'@ + + try { + Write-Host "Writing custom Ventoy configuration. Please wait..." + if (Test-Path -Path "$($volume.DriveLetter):\ventoy\ventoy.json" -PathType Leaf) { + Write-Host "A Ventoy configuration file exists. Moving it..." + Move-Item -Path "$($volume.DriveLetter):\ventoy\ventoy.json" -Destination "$($volume.DriveLetter):\ventoy\ventoy.json.old" -Force + Write-Host "Existing Ventoy configuration has been moved to `"ventoy.json.old`". Feel free to put your config back into the `"ventoy.json`" file." + } + if (-not (Test-Path -Path "$($volume.DriveLetter):\ventoy")) { + New-Item -Path "$($volume.DriveLetter):\ventoy" -ItemType Directory -Force | Out-Null + } + $customVentoyConfig | Out-File -FilePath "$($volume.DriveLetter):\ventoy\ventoy.json" -Encoding utf8 -Force + Write-Host "The Ventoy drive has been successfully configured." + } catch { + Write-Host "Could not configure Ventoy drive. Error: $($_.Exception.Message)`n" + Write-Host "Be sure to add the following configuration to the Ventoy drive by either creating a `"ventoy.json`" file in the `"ventoy`" directory (create it if it doesn't exist) or by editing an existing one: `n`n$customVentoyConfig`n" + Write-Host "Failure to do this will cause conflicts with your target ISO file." + } return } } From 2f8eaf4f18bef8258465155d27f41a56c6238c5f Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Fri, 6 Dec 2024 08:55:02 +0100 Subject: [PATCH 10/10] Add VirtIO functionality and more enhancements - Added the ability to grab VirtIO Guest Tools - Modified the description of the Copy ISO files function because it basically had nonsense --- functions/microwin/Invoke-Microwin.ps1 | 7 ++++ functions/microwin/Invoke-MicrowinGetIso.ps1 | 4 +- functions/microwin/Microwin-CopyVirtIO.ps1 | 40 ++++++++++++++++++++ functions/private/Copy-Files.ps1 | 18 ++++++--- xaml/inputXML.xaml | 1 + 5 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 functions/microwin/Microwin-CopyVirtIO.ps1 diff --git a/functions/microwin/Invoke-Microwin.ps1 b/functions/microwin/Invoke-Microwin.ps1 index 077f4711..1d012613 100644 --- a/functions/microwin/Invoke-Microwin.ps1 +++ b/functions/microwin/Invoke-Microwin.ps1 @@ -55,6 +55,8 @@ public class PowerManagement { $injectDrivers = $sync.MicrowinInjectDrivers.IsChecked $importDrivers = $sync.MicrowinImportDrivers.IsChecked + $importVirtIO = $sync.MicrowinCopyVirtIO.IsChecked + $mountDir = $sync.MicrowinMountDir.Text $scratchDir = $sync.MicrowinScratchDir.Text @@ -155,6 +157,11 @@ public class PowerManagement { } } + if ($importVirtIO) { + Write-Host "Copying VirtIO drivers..." + Microwin-CopyVirtIO + } + Write-Host "Remove Features from the image" Microwin-RemoveFeatures Write-Host "Removing features complete!" diff --git a/functions/microwin/Invoke-MicrowinGetIso.ps1 b/functions/microwin/Invoke-MicrowinGetIso.ps1 index 43f4caed..aa4e9c7c 100644 --- a/functions/microwin/Invoke-MicrowinGetIso.ps1 +++ b/functions/microwin/Invoke-MicrowinGetIso.ps1 @@ -242,8 +242,8 @@ function Invoke-MicrowinGetIso { # xcopy we can verify files and also not copy files that already exist, but hard to measure # xcopy.exe /E /I /H /R /Y /J $DriveLetter":" $mountDir >$null - $totalTime = Measure-Command { Copy-Files "$($driveLetter):" $mountDir -Recurse -Force } - Write-Host "Copy complete! Total Time: $($totalTime.Minutes)m$($totalTime.Seconds)s" + $totalTime = Measure-Command { Copy-Files "$($driveLetter):" "$mountDir" -Recurse -Force } + Write-Host "Copy complete! Total Time: $($totalTime.Minutes) minutes, $($totalTime.Seconds) seconds" $wimFile = "$mountDir\sources\install.wim" Write-Host "Getting image information $wimFile" diff --git a/functions/microwin/Microwin-CopyVirtIO.ps1 b/functions/microwin/Microwin-CopyVirtIO.ps1 new file mode 100644 index 00000000..d050d6dc --- /dev/null +++ b/functions/microwin/Microwin-CopyVirtIO.ps1 @@ -0,0 +1,40 @@ +function Microwin-CopyVirtIO { + <# + .SYNOPSIS + Downloads and copies the VirtIO Guest Tools drivers to the target MicroWin ISO + .NOTES + A network connection must be available and the servers of Fedora People must be up. Automatic driver installation will not be added yet - I want this implementation to be reliable. + #> + + try { + Write-Host "Checking existing files..." + if (Test-Path -Path "$($env:TEMP)\virtio.iso" -PathType Leaf) { + Write-Host "VirtIO ISO has been detected. Deleting..." + Remove-Item -Path "$($env:TEMP)\virtio.iso" -Force + } + Write-Host "Getting latest VirtIO drivers. Please wait. This can take some time, depending on your network connection speed and the speed of the servers..." + Start-BitsTransfer -Source "https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" -Destination "$($env:TEMP)\virtio.iso" -DisplayName "Downloading VirtIO drivers..." + # Do everything else if the VirtIO ISO exists + if (Test-Path -Path "$($env:TEMP)\virtio.iso" -PathType Leaf) { + Write-Host "Mounting ISO. Please wait." + $virtIO_ISO = Mount-DiskImage -PassThru "$($env:TEMP)\virtio.iso" + $driveLetter = (Get-Volume -DiskImage $virtIO_ISO).DriveLetter + # Create new directory for VirtIO on ISO + New-Item -Path "$mountDir\VirtIO" -ItemType Directory | Out-Null + $totalTime = Measure-Command { Copy-Files "$($driveLetter):" "$mountDir\VirtIO" -Recurse -Force } + Write-Host "VirtIO contents have been successfully copied. Time taken: $($totalTime.Minutes) minutes, $($totalTime.Seconds) seconds`n" + Get-Volume $driveLetter | Get-DiskImage | Dismount-DiskImage + Remove-Item -Path "$($env:TEMP)\virtio.iso" -Force -ErrorAction SilentlyContinue + Write-Host "To proceed with installation of the MicroWin image in QEMU/Proxmox VE:" + Write-Host "1. Proceed with Setup until you reach the disk selection screen, in which you won't see any drives" + Write-Host "2. Click `"Load Driver`" and click Browse" + Write-Host "3. In the folder selection dialog, point to this path:`n`n `"D:\VirtIO\vioscsi\w11\amd64`" (replace amd64 with ARM64 if you are using Windows on ARM, and `"D:`" with the drive letter of the ISO)`n" + Write-Host "4. Select all drivers that will appear in the list box and click OK" + } else { + throw "Could not download VirtIO drivers" + } + } catch { + Write-Host "We could not download and/or prepare the VirtIO drivers. Error information: $_`n" + Write-Host "You will need to download these drivers manually. Location: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso" + } +} diff --git a/functions/private/Copy-Files.ps1 b/functions/private/Copy-Files.ps1 index fafb4b51..cec7869a 100644 --- a/functions/private/Copy-Files.ps1 +++ b/functions/private/Copy-Files.ps1 @@ -2,11 +2,17 @@ function Copy-Files { <# .DESCRIPTION - This function will make all modifications to the registry - + Copies the contents of a given ISO file to a given destination + .PARAMETER Path + The source of the files to copy + .PARAMETER Destination + The destination to copy the files to + .PARAMETER Recurse + Determines whether or not to copy all files of the ISO file, including those in subdirectories + .PARAMETER Force + Determines whether or not to overwrite existing files .EXAMPLE - - Set-WinUtilRegistry -Name "PublishUserActivities" -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Type "DWord" -Value "0" + Copy-Files "D:" "C:\ISOFile" -Recurse -Force #> param ( @@ -23,7 +29,7 @@ function Copy-Files { foreach ($file in $files) { $status = "Copying file {0} of {1}: {2}" -f $counter, $files.Count, $file.Name - Write-Progress -Activity "Copy Windows files" -Status $status -PercentComplete ($counter++/$files.count*100) + Write-Progress -Activity "Copy disc image files" -Status $status -PercentComplete ($counter++/$files.count*100) $restpath = $file.FullName -Replace $path, '' if ($file.PSIsContainer -eq $true) { @@ -35,7 +41,7 @@ function Copy-Files { Set-ItemProperty -Path ($destination+$restpath) -Name IsReadOnly -Value $false } } - Write-Progress -Activity "Copy Windows files" -Status "Ready" -Completed + Write-Progress -Activity "Copy disc image files" -Status "Ready" -Completed } catch { Write-Host "Unable to Copy all the files due to an unhandled exception" -ForegroundColor Yellow Write-Host "Error information: $($_.Exception.Message)`n" -ForegroundColor Yellow diff --git a/xaml/inputXML.xaml b/xaml/inputXML.xaml index c8eb4100..5f36750f 100644 --- a/xaml/inputXML.xaml +++ b/xaml/inputXML.xaml @@ -1175,6 +1175,7 @@ ToolTip="Path to unpacked drivers all sys and inf files for devices that need drivers" /> <CheckBox Name="MicrowinImportDrivers" Content="Import drivers from current system" Margin="{DynamicResource MicrowinCheckBoxMargin}" IsChecked="False" ToolTip="Export all third-party drivers from your system and inject them to the MicroWin image"/> + <CheckBox Name="MicrowinCopyVirtIO" Content="Include VirtIO drivers" Margin="{DynamicResource MicrowinCheckBoxMargin}" IsChecked="False" ToolTip="Copy VirtIO Guest Tools drivers to your ISO file. Check this only if you want to use it on QEMU/Proxmox VE"/> <Rectangle Fill="{DynamicResource MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/> <CheckBox Name="WPFMicrowinCopyToUsb" Content="Copy to Ventoy" Margin="{DynamicResource MicrowinCheckBoxMargin}" IsChecked="False" ToolTip="Copy to USB disk with a label Ventoy"/> <Rectangle Fill="{DynamicResource MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/>