Compare commits

...

1 Commits

Author SHA1 Message Date
3c16156644 Added ability to import drivers
Added the ability to import drivers from the active installation to the MicroWin image.
2024-04-21 09:11:10 +02:00
2 changed files with 28 additions and 2 deletions

View File

@ -53,6 +53,7 @@ public class PowerManagement {
$keepEdge = $sync.WPFMicrowinKeepEdge.IsChecked
$copyToUSB = $sync.WPFMicrowinCopyToUsb.IsChecked
$injectDrivers = $sync.MicrowinInjectDrivers.IsChecked
$importDrivers = $sync.MicrowinImportDrivers.IsChecked
$mountDir = $sync.MicrowinMountDir.Text
$scratchDir = $sync.MicrowinScratchDir.Text
@ -117,7 +118,7 @@ public class PowerManagement {
if (Test-Path $driverPath)
{
Write-Host "Adding Windows Drivers image($scratchDir) drivers($driverPath) "
Add-WindowsDriver -Path "$scratchDir" -Recurse -Driver "$driverPath"
dism /English /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host
}
else
{
@ -125,6 +126,30 @@ public class PowerManagement {
}
}
if ($importDrivers)
{
Write-Host "Exporting drivers from active installation..."
if (Test-Path "$env:TEMP\DRV_EXPORT")
{
Remove-Item "$env:TEMP\DRV_EXPORT" -Recurse -Force
}
New-Item -Path "$env:TEMP\DRV_EXPORT" -ItemType Directory -Force
dism /english /online /export-driver /destination="$env:TEMP\DRV_EXPORT" | Out-Host
if ($?)
{
Write-Host "Adding exported drivers..."
dism /english /image="$scratchDir" /add-driver /driver="$env:TEMP\DRV_EXPORT" /recurse | Out-Host
}
else
{
Write-Host "Failed to export drivers. Continuing without importing them..."
}
if (Test-Path "$env:TEMP\DRV_EXPORT")
{
Remove-Item "$env:TEMP\DRV_EXPORT" -Recurse -Force
}
}
Write-Host "Remove Features from the image"
Remove-Features -keepDefender:$keepDefender
Write-Host "Removing features complete!"
@ -335,7 +360,7 @@ public class PowerManagement {
if (Test-Path $driverPath)
{
Write-Host "Adding Windows Drivers image($scratchDir) drivers($driverPath) "
Add-WindowsDriver -Path "$scratchDir" -Driver "$driverPath" -Recurse
dism /English /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host
}
else
{

View File

@ -843,6 +843,7 @@
Foreground="{LabelboxForegroundColor}"
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="5,0" IsChecked="False" ToolTip="Export all third-party drivers from your system and inject them to the MicroWin image (DO NOTE THAT THIS MAY DAMAGE THE COMPONENT STORE OF THE IMAGE)"/>
<Rectangle Fill="{MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/>
<CheckBox Name="WPFMicrowinCopyToUsb" Content="Copy to Ventoy" Margin="5,0" IsChecked="False" ToolTip="Copy to USB disk with a label Ventoy"/>
<Rectangle Fill="{MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/>