[MicroWin] Add automatic configuration settings

This commit is contained in:
CodingWonders
2024-08-24 19:49:27 +02:00
parent bcfbce66fd
commit 1f52790241
5 changed files with 75 additions and 2 deletions

View File

@ -0,0 +1,24 @@
function Invoke-AutoConfigDialog {
<#
.SYNOPSIS
Sets the automatic configuration file based on a specified JSON file
#>
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
$OFD = New-Object System.Windows.Forms.OpenFileDialog
$OFD.Filter = "JSON Files (*.json)|*.json"
$OFD.ShowDialog()
if (($OFD.FileName -eq "") -and ($sync.MicrowinAutoConfigBox.Text -eq ""))
{
Write-Host "No automatic config file has been selected. Continuing without one..."
return
}
elseif ($OFD.FileName -ne "")
{
$sync.MicrowinAutoConfigBox.Text = "$($OFD.FileName)"
}
}

View File

@ -57,5 +57,6 @@ function Invoke-WPFButton {
"WPFMicrowin" {Invoke-WPFMicrowin}
"WPFCloseButton" {Invoke-WPFCloseButton}
"MicrowinScratchDirBT" {Invoke-ScratchDialog}
"MicrowinAutoConfigBtn" {Invoke-AutoConfigDialog}
}
}

View File

@ -178,7 +178,21 @@ public class PowerManagement {
Write-Host "Removal complete!"
Write-Host "Create unattend.xml"
#New-Unattend
if (($sync.MicrowinAutoConfigBox.Text -ne "") -and (Test-Path "$($sync.MicrowinAutoConfigBox.Text)"))
{
try
{
Write-Host "A configuration file has been specified. Copying to WIM file..."
Copy-Item "$($sync.MicrowinAutoConfigBox.Text)" "$($scratchDir)\winutil-config.json"
}
catch
{
Write-Host "The config file could not be copied. Continuing without it..."
}
}
# Create unattended answer file with user information - Check condition to learn more about this functionality
if ($sync.MicrowinUserName.Text -eq "")
{
New-Unattend -userName "User"