mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-07-04 04:03:52 -05:00
[MicroWin] Add automatic configuration settings
This commit is contained in:
24
functions/public/Invoke-AutoConfigDialog.ps1
Normal file
24
functions/public/Invoke-AutoConfigDialog.ps1
Normal 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)"
|
||||
}
|
||||
}
|
@ -57,5 +57,6 @@ function Invoke-WPFButton {
|
||||
"WPFMicrowin" {Invoke-WPFMicrowin}
|
||||
"WPFCloseButton" {Invoke-WPFCloseButton}
|
||||
"MicrowinScratchDirBT" {Invoke-ScratchDialog}
|
||||
"MicrowinAutoConfigBtn" {Invoke-AutoConfigDialog}
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
|
Reference in New Issue
Block a user