Skip to content

Commit

Permalink
[MicroWin] Add custom user settings and other changes (docs/bugfixes) (
Browse files Browse the repository at this point in the history
…#2575)

* [MicroWin] Add custom user settings

* Update inputXML.xaml

* Update MicroWin documentation to reflect changes

* Update Invoke-WinUtilMicroWin-Helper.ps1

* Update Invoke-WPFMicrowin.ps1
  • Loading branch information
CodingWonders authored Aug 19, 2024
1 parent 83fe6c5 commit 2748767
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 27 deletions.
29 changes: 9 additions & 20 deletions docs/userguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,34 +198,23 @@ 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.
* 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.
##### Driver integration options

* **Keep Edge**: leaving this option unticked will try to remove every part of the Microsoft Edge browser using the best methods available.
* **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.

    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)
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

##### Driver integration options
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.

* **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.
!!! info

    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.
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
Expand Down
18 changes: 14 additions & 4 deletions functions/private/Invoke-WinUtilMicroWin-Helper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ function Remove-FileOrDirectory([string]$pathToDelete, [string]$mask = "", [swit

function New-Unattend {

param (
[Parameter(Mandatory, Position = 0)] [string] $userName,
[Parameter(Position = 1)] [string] $userPassword
)

$unattend = @'
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend"
Expand All @@ -269,21 +274,21 @@ function New-Unattend {
<UserAccounts>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Name>User</Name>
<Name>USER-REPLACEME</Name>
<Group>Administrators</Group>
<Password>
<Value></Value>
<Value>PW-REPLACEME</Value>
<PlainText>true</PlainText>
</Password>
</LocalAccount>
</LocalAccounts>
</UserAccounts>
<AutoLogon>
<Username>User</Username>
<Username>USER-REPLACEME</Username>
<Enabled>true</Enabled>
<LogonCount>1</LogonCount>
<Password>
<Value></Value>
<Value>PW-REPLACEME</Value>
<PlainText>true</PlainText>
</Password>
</AutoLogon>
Expand Down Expand Up @@ -543,6 +548,11 @@ function New-Unattend {
# Replace the placeholder text with the Specialize pass
$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
}

Expand Down
22 changes: 20 additions & 2 deletions functions/public/Invoke-WPFMicrowin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,22 @@ public class PowerManagement {
Write-Host "Removal complete!"

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 "Copy unattend.xml file into the ISO"
New-Item -ItemType Directory -Force -Path "$($scratchDir)\Windows\Panther"
Expand Down Expand Up @@ -248,7 +263,10 @@ public class PowerManagement {
# reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\$_" /f | Out-Null

# When in Offline Image
reg delete "HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\$_" /f | Out-Null
if (Test-Path "HKLM:\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\$_")
{
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
Expand Down
49 changes: 48 additions & 1 deletion xaml/inputXML.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,36 @@
</Setter.Value>
</Setter>
</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">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
Expand Down Expand Up @@ -921,6 +951,23 @@
<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"/>
<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"/>
</StackPanel>
<StackPanel HorizontalAlignment="Left" SnapsToDevicePixels="True" Margin="1" Visibility="Collapsed">
Expand Down Expand Up @@ -968,7 +1015,7 @@
Foreground="{ComboBoxForegroundColor}">
<Bold>MicroWin features:</Bold><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/>
- Apps debloat <LineBreak/>
<LineBreak/>
Expand Down

0 comments on commit 2748767

Please sign in to comment.