diff --git a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1
index b568b839..5a215392 100644
--- a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1
+++ b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1
@@ -248,7 +248,7 @@ function Remove-FileOrDirectory([string]$pathToDelete, [string]$mask = "", [swit
function New-Unattend {
param (
- [Parameter(Mandatory, Position = 0)] [string] $userName,
+ [Parameter(Mandatory, Position = 0)] [string]$userName,
[Parameter(Position = 1)] [string] $userPassword
)
@@ -719,6 +719,12 @@ function New-FirstRun {
# Done create WinUtil shortcut on the desktop
# ************************************************
+ if (Test-Path -Path "$env:HOMEDRIVE\winutil-config.json")
+ {
+ Write-Host "Configuration file detected. Applying..."
+ iex "& { $(irm christitus.com/win) } -Config `"$env:HOMEDRIVE\winutil-config.json`" -Run"
+ }
+
Start-Process explorer
'@
diff --git a/functions/public/Invoke-AutoConfigDialog.ps1 b/functions/public/Invoke-AutoConfigDialog.ps1
new file mode 100644
index 00000000..cc6cc2fa
--- /dev/null
+++ b/functions/public/Invoke-AutoConfigDialog.ps1
@@ -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)"
+ }
+}
diff --git a/functions/public/Invoke-WPFButton.ps1 b/functions/public/Invoke-WPFButton.ps1
index ac5b2f8c..3b342d3c 100644
--- a/functions/public/Invoke-WPFButton.ps1
+++ b/functions/public/Invoke-WPFButton.ps1
@@ -57,5 +57,6 @@ function Invoke-WPFButton {
"WPFMicrowin" {Invoke-WPFMicrowin}
"WPFCloseButton" {Invoke-WPFCloseButton}
"MicrowinScratchDirBT" {Invoke-ScratchDialog}
+ "MicrowinAutoConfigBtn" {Invoke-AutoConfigDialog}
}
}
diff --git a/functions/public/Invoke-WPFMicrowin.ps1 b/functions/public/Invoke-WPFMicrowin.ps1
index 78cced29..737f6941 100644
--- a/functions/public/Invoke-WPFMicrowin.ps1
+++ b/functions/public/Invoke-WPFMicrowin.ps1
@@ -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"
diff --git a/xaml/inputXML.xaml b/xaml/inputXML.xaml
index 332122b0..f90f955e 100644
--- a/xaml/inputXML.xaml
+++ b/xaml/inputXML.xaml
@@ -968,6 +968,34 @@
Foreground="{LabelboxForegroundColor}"
/>
+ Automatic configuration (optional):
+ WinUtil configuration file (JSON)
+
+
+
+
+
+
+
+
+
+