[MicroWin] Add custom user settings and other changes (docs/bugfixes) (#2575)

* [MicroWin] Add custom user settings

* Update inputXML.xaml

* Update MicroWin documentation to reflect changes

* Update Invoke-WinUtilMicroWin-Helper.ps1

* Update Invoke-WPFMicrowin.ps1
This commit is contained in:
CodingWonders 2024-08-19 21:21:12 +02:00 committed by GitHub
parent 83fe6c5b12
commit 2748767a47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 92 additions and 28 deletions

View File

@ -198,26 +198,7 @@ The utility provides three distinct settings for managing Windows updates: Defau
* Selecting a scratch directory will copy the contents of the ISO file to the directory you specify instead of an automatically generated folder in the `%TEMP%` directory. * Selecting a scratch directory will copy the contents of the ISO file to the directory you specify instead of an automatically generated folder in the `%TEMP%` directory.
* You can select an edition of Windows to debloat (**SKU**) using the convenient drop-down menu. * You can select an edition of Windows to debloat (**SKU**) using the convenient drop-down menu.
    By default, MicroWin will debloat the Pro edition, but you can choose any edition you want. By default, MicroWin will debloat the Pro edition, but you can choose any edition you want.
##### Customization options
* **Keep Provisioned Packages**: leaving this option unticked (default) will try to remove every operating system package.
    Some packages may remain after processing. This can happen if the packages in question are permanent or have been superseded by newer versions.
* **Keep Appx Packages**: leaving this option unticked (default) will try to remove every Microsoft Store app from the Windows image.
    This option will exclude some applications that are essential in the event that you want or need to add a Store app later on.
* **Keep Defender**: leaving this option unticked will try to remove every part of Windows Defender, including the Windows Security app.
    Leaving this option unticked is **NOT recommended** unless you plan to use a third-party antivirus solution on your MicroWin installation. In that regard, don't install AVs with bad reputations or rogueware.
* **Keep Edge**: leaving this option unticked will try to remove every part of the Microsoft Edge browser using the best methods available.
    Leaving this option unticked is not recommended because it might break some applications that might depend on the `Edge WebView2` runtime. However, if that happens, you can easily [reinstall it](https://developer.microsoft.com/en-us/microsoft-edge/webview2)
##### Driver integration options ##### Driver integration options
@ -225,7 +206,15 @@ The utility provides three distinct settings for managing Windows updates: Defau
* **Inject drivers** will add the drivers in the folder that you specify to the target Windows image. * **Inject drivers** will add the drivers in the folder that you specify to the target Windows image.
* **Import drivers from the current system** will add every third-party driver that is present in your active installation. * **Import drivers from the current system** will add every third-party driver that is present in your active installation.
    This makes the target image have the same hardware compatibility as the active installation. However, this means that you will only be able to install the target Windows image and take full advantage of it on computers with **the same hardware**. To avoid this, you'll need to customize the `install.wim` file of the target ISO in the 'sources` folder. This makes the target image have the same hardware compatibility as the active installation. However, this means that you will only be able to install the target Windows image and take full advantage of it on computers with **the same hardware**. To avoid this, you'll need to customize the `install.wim` file of the target ISO in the 'sources` folder.
##### Custom user settings
With MicroWin, you can also configure your user before proceeding if you don't want to use the default `User` account. To do this, simply type the account name (20 characters maximum), and a password. Then, let MicroWin do the rest.
!!! info
Please make sure that you remember your password. MicroWin will configure auto-login settings, so you won't have to enter your password. However, if you are required to enter your password, it's best that you don't forget it.
##### Ventoy options ##### Ventoy options

View File

@ -247,6 +247,11 @@ function Remove-FileOrDirectory([string]$pathToDelete, [string]$mask = "", [swit
function New-Unattend { function New-Unattend {
param (
[Parameter(Mandatory, Position = 0)] [string] $userName,
[Parameter(Position = 1)] [string] $userPassword
)
$unattend = @' $unattend = @'
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend" <unattend xmlns="urn:schemas-microsoft-com:unattend"
@ -269,21 +274,21 @@ function New-Unattend {
<UserAccounts> <UserAccounts>
<LocalAccounts> <LocalAccounts>
<LocalAccount wcm:action="add"> <LocalAccount wcm:action="add">
<Name>User</Name> <Name>USER-REPLACEME</Name>
<Group>Administrators</Group> <Group>Administrators</Group>
<Password> <Password>
<Value></Value> <Value>PW-REPLACEME</Value>
<PlainText>true</PlainText> <PlainText>true</PlainText>
</Password> </Password>
</LocalAccount> </LocalAccount>
</LocalAccounts> </LocalAccounts>
</UserAccounts> </UserAccounts>
<AutoLogon> <AutoLogon>
<Username>User</Username> <Username>USER-REPLACEME</Username>
<Enabled>true</Enabled> <Enabled>true</Enabled>
<LogonCount>1</LogonCount> <LogonCount>1</LogonCount>
<Password> <Password>
<Value></Value> <Value>PW-REPLACEME</Value>
<PlainText>true</PlainText> <PlainText>true</PlainText>
</Password> </Password>
</AutoLogon> </AutoLogon>
@ -543,6 +548,11 @@ function New-Unattend {
# Replace the placeholder text with the Specialize pass # Replace the placeholder text with the Specialize pass
$unattend = $unattend.Replace("<#REPLACEME#>", $specPass).Trim() $unattend = $unattend.Replace("<#REPLACEME#>", $specPass).Trim()
} }
# Replace default User and Password values with the provided parameters
$unattend = $unattend.Replace("USER-REPLACEME", $userName).Trim()
$unattend = $unattend.Replace("PW-REPLACEME", $userPassword).Trim()
# Save unattended answer file with UTF-8 encoding
$unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force -Encoding utf8 $unattend | Out-File -FilePath "$env:temp\unattend.xml" -Force -Encoding utf8
} }

View File

@ -178,7 +178,22 @@ public class PowerManagement {
Write-Host "Removal complete!" Write-Host "Removal complete!"
Write-Host "Create unattend.xml" Write-Host "Create unattend.xml"
New-Unattend #New-Unattend
if ($sync.MicrowinUserName.Text -eq "")
{
New-Unattend -userName "User"
}
else
{
if ($sync.MicrowinUserPassword.Password -eq "")
{
New-Unattend -userName "$($sync.MicrowinUserName.Text)"
}
else
{
New-Unattend -userName "$($sync.MicrowinUserName.Text)" -userPassword "$($sync.MicrowinUserPassword.Password)"
}
}
Write-Host "Done Create unattend.xml" Write-Host "Done Create unattend.xml"
Write-Host "Copy unattend.xml file into the ISO" Write-Host "Copy unattend.xml file into the ISO"
New-Item -ItemType Directory -Force -Path "$($scratchDir)\Windows\Panther" New-Item -ItemType Directory -Force -Path "$($scratchDir)\Windows\Panther"
@ -248,8 +263,11 @@ public class PowerManagement {
# reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\$_" /f | Out-Null # reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\$_" /f | Out-Null
# When in Offline Image # When in Offline Image
if (Test-Path "HKLM:\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\$_")
{
reg delete "HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\$_" /f | Out-Null reg delete "HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\$_" /f | Out-Null
} }
}
reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "SearchboxTaskbarMode" /t REG_DWORD /d 0 /f reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "SearchboxTaskbarMode" /t REG_DWORD /d 0 /f
Write-Host "Setting all services to start manually" Write-Host "Setting all services to start manually"

View File

@ -566,6 +566,36 @@
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
<Style TargetType="PasswordBox">
<Setter Property="Background" Value="{MainBackgroundColor}"/>
<Setter Property="BorderBrush" Value="{MainForegroundColor}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{MainForegroundColor}"/>
<Setter Property="FontSize" Value="{FontSize}"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="PasswordBox">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="5">
<Grid>
<ScrollViewer x:Name="PART_ContentHost" />
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect ShadowDepth="5" BlurRadius="5" Opacity="{BorderOpacity}" Color="{BorderColor}"/>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ScrollVisibilityRectangle" TargetType="Rectangle"> <Style x:Key="ScrollVisibilityRectangle" TargetType="Rectangle">
<Setter Property="Visibility" Value="Collapsed"/> <Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers> <Style.Triggers>
@ -921,6 +951,23 @@
<Rectangle Fill="{MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/> <Rectangle Fill="{MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/>
<CheckBox Name="WPFMicrowinCopyToUsb" Content="Copy to Ventoy" Margin="-10,5,0,0" IsChecked="False" ToolTip="Copy to USB disk with a label Ventoy"/> <CheckBox Name="WPFMicrowinCopyToUsb" Content="Copy to Ventoy" Margin="-10,5,0,0" IsChecked="False" ToolTip="Copy to USB disk with a label Ventoy"/>
<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>Custom user settings (leave empty for default user)</Bold></TextBlock>
<TextBlock Margin="6" Padding="1" TextWrapping="Wrap">User name (20 characters max.):</TextBlock>
<TextBox Name="MicrowinUserName" Background="Transparent" BorderThickness="1" BorderBrush="{MainForegroundColor}"
Margin="6"
Text=""
IsReadOnly="False"
TextWrapping="Wrap"
Foreground="{LabelboxForegroundColor}"
MaxLength="20"
/>
<TextBlock Margin="6" Padding="1" TextWrapping="Wrap">Password (characters will not be shown for your security):</TextBlock>
<PasswordBox Name="MicrowinUserPassword" Background="Transparent" BorderThickness="1" BorderBrush="{MainForegroundColor}"
Margin="6"
PasswordChar="*"
Foreground="{LabelboxForegroundColor}"
/>
<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">
@ -968,7 +1015,7 @@
Foreground="{ComboBoxForegroundColor}"> Foreground="{ComboBoxForegroundColor}">
<Bold>MicroWin features:</Bold><LineBreak/> <Bold>MicroWin features:</Bold><LineBreak/>
- Remove Telemetry and Tracking <LineBreak/> - Remove Telemetry and Tracking <LineBreak/>
- Fast Install using "User" local account <LineBreak/> - Fast Install using either the "User" local account or the account of your choosing <LineBreak/>
- No internet requirement for install <LineBreak/> - No internet requirement for install <LineBreak/>
- Apps debloat <LineBreak/> - Apps debloat <LineBreak/>
<LineBreak/> <LineBreak/>