mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-16 01:40:35 -06:00
[MicroWin] Add automatic configuration settings
This commit is contained in:
parent
bcfbce66fd
commit
1f52790241
@ -248,7 +248,7 @@ function Remove-FileOrDirectory([string]$pathToDelete, [string]$mask = "", [swit
|
|||||||
function New-Unattend {
|
function New-Unattend {
|
||||||
|
|
||||||
param (
|
param (
|
||||||
[Parameter(Mandatory, Position = 0)] [string] $userName,
|
[Parameter(Mandatory, Position = 0)] [string]$userName,
|
||||||
[Parameter(Position = 1)] [string] $userPassword
|
[Parameter(Position = 1)] [string] $userPassword
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -719,6 +719,12 @@ function New-FirstRun {
|
|||||||
# Done create WinUtil shortcut on the desktop
|
# 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
|
Start-Process explorer
|
||||||
|
|
||||||
'@
|
'@
|
||||||
|
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}
|
"WPFMicrowin" {Invoke-WPFMicrowin}
|
||||||
"WPFCloseButton" {Invoke-WPFCloseButton}
|
"WPFCloseButton" {Invoke-WPFCloseButton}
|
||||||
"MicrowinScratchDirBT" {Invoke-ScratchDialog}
|
"MicrowinScratchDirBT" {Invoke-ScratchDialog}
|
||||||
|
"MicrowinAutoConfigBtn" {Invoke-AutoConfigDialog}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,21 @@ public class PowerManagement {
|
|||||||
Write-Host "Removal complete!"
|
Write-Host "Removal complete!"
|
||||||
|
|
||||||
Write-Host "Create unattend.xml"
|
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 "")
|
if ($sync.MicrowinUserName.Text -eq "")
|
||||||
{
|
{
|
||||||
New-Unattend -userName "User"
|
New-Unattend -userName "User"
|
||||||
|
@ -968,6 +968,34 @@
|
|||||||
Foreground="{LabelboxForegroundColor}"
|
Foreground="{LabelboxForegroundColor}"
|
||||||
/>
|
/>
|
||||||
<Rectangle Fill="{MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/>
|
<Rectangle Fill="{MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/>
|
||||||
|
<TextBlock Margin="6" Padding="1" TextWrapping="Wrap"><Bold>Automatic configuration (optional):</Bold></TextBlock>
|
||||||
|
<TextBlock Margin="6" Padding="1" TextWrapping="Wrap">WinUtil configuration file (JSON)</TextBlock>
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" /> <!-- Takes the remaining space -->
|
||||||
|
<ColumnDefinition Width="32" /> <!-- Fixed width for Button -->
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBox Name="MicrowinAutoConfigBox" Background="Transparent" BorderBrush="{MainForegroundColor}"
|
||||||
|
Text=""
|
||||||
|
Margin="2"
|
||||||
|
IsReadOnly="False"
|
||||||
|
ToolTip="Path of your configuration file"
|
||||||
|
Grid.Column="0"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Foreground="{LabelboxForegroundColor}">
|
||||||
|
</TextBox>
|
||||||
|
<Button Name="MicrowinAutoConfigBtn"
|
||||||
|
Width="Auto"
|
||||||
|
Height="Auto"
|
||||||
|
Grid.Column="1"
|
||||||
|
Margin="2"
|
||||||
|
Padding="1" VerticalAlignment="Center">
|
||||||
|
<Button.Content>
|
||||||
|
...
|
||||||
|
</Button.Content>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
<Rectangle Fill="{MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/>
|
||||||
<Button Name="WPFMicrowin" Content="Start the process" Margin="2" Padding="15"/>
|
<Button Name="WPFMicrowin" Content="Start the process" Margin="2" Padding="15"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel HorizontalAlignment="Left" SnapsToDevicePixels="True" Margin="1" Visibility="Collapsed">
|
<StackPanel HorizontalAlignment="Left" SnapsToDevicePixels="True" Margin="1" Visibility="Collapsed">
|
||||||
|
Loading…
Reference in New Issue
Block a user