winutil/functions/microwin/Microwin-NewFirstRun.ps1

119 lines
5.7 KiB
PowerShell
Raw Normal View History

function Microwin-NewFirstRun {
2025-10-14 19:51:53 +02:00
# using here string to embed firstrun
$firstRun = @'
# Set the global error action preference to continue
$ErrorActionPreference = "Continue"
function Remove-RegistryValue {
param (
[Parameter(Mandatory = $true)]
[string]$RegistryPath,
[Parameter(Mandatory = $true)]
[string]$ValueName
)
# Check if the registry path exists
if (Test-Path -Path $RegistryPath) {
$registryValue = Get-ItemProperty -Path $RegistryPath -Name $ValueName -ErrorAction SilentlyContinue
# Check if the registry value exists
if ($registryValue) {
# Remove the registry value
Remove-ItemProperty -Path $RegistryPath -Name $ValueName -Force
Write-Host "Registry value '$ValueName' removed from '$RegistryPath'."
} else {
Write-Host "Registry value '$ValueName' not found in '$RegistryPath'."
}
} else {
Write-Host "Registry path '$RegistryPath' not found."
}
}
"FirstStartup has worked" | Out-File -FilePath "$env:HOMEDRIVE\windows\LogFirstRun.txt" -Append -NoClobber
$taskbarPath = "$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
# Delete all files on the Taskbar
if (Test-Path "$taskbarPath") {
Get-ChildItem -Path $taskbarPath -File | Remove-Item -Force
}
Remove-RegistryValue -RegistryPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -ValueName "FavoritesRemovedChanges"
Remove-RegistryValue -RegistryPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -ValueName "FavoritesChanges"
Remove-RegistryValue -RegistryPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -ValueName "Favorites"
# Delete Edge Icon from the desktop
$edgeShortcutFiles = Get-ChildItem -Path $desktopPath -Filter "*Edge*.lnk"
# Check if Edge shortcuts exist on the desktop
if ($edgeShortcutFiles) {
foreach ($shortcutFile in $edgeShortcutFiles) {
# Remove each Edge shortcut
Remove-Item -Path $shortcutFile.FullName -Force
Write-Host "Edge shortcut '$($shortcutFile.Name)' removed from the desktop."
}
}
Remove-Item -Path "$env:USERPROFILE\Desktop\*.lnk"
Remove-Item -Path "$env:HOMEDRIVE\Users\Default\Desktop\*.lnk"
try
{
if ((Get-WindowsOptionalFeature -Online | Where-Object { $_.State -eq 'Enabled' -and $_.FeatureName -like "Recall" }).Count -gt 0)
{
Disable-WindowsOptionalFeature -Online -FeatureName "Recall" -Remove
}
}
catch
{
}
[MicroWin] Preparation for 2025 (#3066) * Set Boot Manager entry timeout to 0 Fixes #2562 * Exclude Windows Hello stuff from package removal * Obscure passwords with Base64 and fix indentation Fixes #3064 * Fix name of excluded package * Update comment It reflects my feelings towards Microsoft when it comes to security a lot better * Remove jargon of scratch directory options * Package exclusion improvements - Removed AppX packages from OS package exclusion list - Added exclusion of PowerShell ISE (source: Discord server - yes, some people still use the PowerShell ISE) * Exclude Windows Photo Viewer from dir removal * Improve copy operation to Ventoy drives This change may fix the issues where there's a conflict between both Ventoy's and MicroWin's unattended answer files, causing target images to stop working as expected during OOBE * Add VirtIO functionality and more enhancements - Added the ability to grab VirtIO Guest Tools - Modified the description of the Copy ISO files function because it basically had nonsense * Fix typo (#3104) * Access specific property of ISO image object Only show the ISO path. No one is interested in the storage type * Add detections for expedited app removal They only affect 24H2 and newer. Earlier releases don't have these expedited apps * Update message * Add VirtIO instructions to MicroWin page * Add DISM command fallback This fallback is triggered if an exception occurs while getting information with the cmdlets (I couldn't test this on my host as everything magically works now - sometimes it threw the Class not registered error) * Exclude OpenSSH from package removal Some people need this to avoid installing third-party programs like PuTTY * Fixed some more indentation
2025-01-10 20:40:25 +01:00
# Get BCD entries and set bootmgr timeout accordingly
try
{
# Check if the number of occurrences of "path" is 2 - this fixes the Boot Manager screen issue (#2562)
if ((bcdedit | Select-String "path").Count -eq 2)
{
# Set bootmgr timeout to 0
bcdedit /set `{bootmgr`} timeout 0
}
}
catch
{
}
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.Suggested" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.Suggested" /v Enabled /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.StartupApp" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.StartupApp" /v Enabled /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.SkyDrive.Desktop" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.SkyDrive.Desktop" /v Enabled /t REG_DWORD /d 0 /f
[MicroWin] June-August 2025 Update (#3417) * Disable "Microsoft account" notification source * [WinPE] Remove driver addition block for WinPE WE DO NOT TOUCH THE DRIVERS IN WinPE. There are reports of people getting "Install driver to show hardware" screens all over this repository, and on Discord; and the less drivers we touch in WinPE, the better. Drivers can still be added to Preinstallation Environments in the following ways: - Using the driver installation screens - Firing up "drvload.exe <driver>" in cmd * [Fix] Added fallback for DISM export command This is a port of the fix in #3305 * [Cleanup] Removed some comments that no longer make sense * [Fix] Same DISM export image fallback fix * Merge branch 'main' into microwin-202506 * [Fix] Improve UI consistency for instructions Fixes #3394 * Merge branch 'main' into microwin-202506 * [Unattended answer file] Remove it from drive root The answer file, on the drive root, is not necessary for us to apply it. In fact, it's not even used there * Merge branch 'main' into microwin-202506 * [MicroWin] June-August 2025 Update (#3) -- Contributions from Callum * Allow people without compatible hardware or a USB to use MicroWin. * Update functions/microwin/Microwin-NewUnattend.ps1 Co-authored-by: CodingWonders <101426328+CodingWonders@users.noreply.github.com> * Update Invoke-Microwin.ps1 * Update Microwin-NewUnattend.ps1 * Update Microwin-NewUnattend.ps1 * Add error pop up if ISO Creation fails. Issue 2653 * Add Disable WPBT Execution to MicroWin. * Update functions/microwin/Invoke-Microwin.ps1 Co-authored-by: CodingWonders <101426328+CodingWonders@users.noreply.github.com> * modified: functions/microwin/Invoke-Microwin.ps1 modified: xaml/inputXML.xaml --------- Co-authored-by: CodingWonders <101426328+CodingWonders@users.noreply.github.com> * Add conversion to ESD (#4) * Add conversion to ESD Issue - #3450 * Update Invoke-Microwin.ps1 Added quotes to the file paths. Put all the arguments in 1 string (as that also works fine) --------- Co-authored-by: CodingWonders <101426328+CodingWonders@users.noreply.github.com> * Update MicroWin contributor list * Merge branch 'main' into microwin-202506 * Merge branch 'main' into microwin-202506 * [MicroWin] Add automatic configuration settings Originally implemented in #2618. Adapted to follow the new file structure. And it works. Though there are issues that will be detailed very soon * [Fix] Fixed typos, updated descriptions * Re-add WinPE driver addition We're not yet sure if that is the actual problem of missing storage controllers. Logs can tell us more about this. Maybe for a future PR? * [Fix/WPBT] Add spaces to reg key path Avoid REG failure * [Fix/XAML] Fix word wrapping issue for checkboxes
2025-08-05 18:24:59 +02:00
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.AccountHealth" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.AccountHealth" /v Enabled /t REG_DWORD /d 0 /f
# This will set List view in Start menu on Win11 25H2. This will not do anything in 24H2 and older
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Start" /v AllAppsViewMode /t REG_DWORD /d 2 /f
# This will disable the Recommendations in 25H2. This is much simpler than the method used in 24H2 that requires the Education Environment policy
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Start_IrisRecommendations /t REG_DWORD /d 0 /f
# Other Start Menu settings
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Start_AccountNotifications /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Start" /v ShowAllPinsList /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Start" /v ShowFrequentList /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Start" /v ShowRecentList /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Start_TrackDocs /t REG_DWORD /d 0 /f
Clear-Host
Write-Host "The taskbar will take around a minute to show up, but you can start using your computer now. Try pressing the Windows key to open the Start menu, or Windows + E to launch File Explorer."
Start-Sleep -Seconds 10
[MicroWin] June-August 2025 Update (#3417) * Disable "Microsoft account" notification source * [WinPE] Remove driver addition block for WinPE WE DO NOT TOUCH THE DRIVERS IN WinPE. There are reports of people getting "Install driver to show hardware" screens all over this repository, and on Discord; and the less drivers we touch in WinPE, the better. Drivers can still be added to Preinstallation Environments in the following ways: - Using the driver installation screens - Firing up "drvload.exe <driver>" in cmd * [Fix] Added fallback for DISM export command This is a port of the fix in #3305 * [Cleanup] Removed some comments that no longer make sense * [Fix] Same DISM export image fallback fix * Merge branch 'main' into microwin-202506 * [Fix] Improve UI consistency for instructions Fixes #3394 * Merge branch 'main' into microwin-202506 * [Unattended answer file] Remove it from drive root The answer file, on the drive root, is not necessary for us to apply it. In fact, it's not even used there * Merge branch 'main' into microwin-202506 * [MicroWin] June-August 2025 Update (#3) -- Contributions from Callum * Allow people without compatible hardware or a USB to use MicroWin. * Update functions/microwin/Microwin-NewUnattend.ps1 Co-authored-by: CodingWonders <101426328+CodingWonders@users.noreply.github.com> * Update Invoke-Microwin.ps1 * Update Microwin-NewUnattend.ps1 * Update Microwin-NewUnattend.ps1 * Add error pop up if ISO Creation fails. Issue 2653 * Add Disable WPBT Execution to MicroWin. * Update functions/microwin/Invoke-Microwin.ps1 Co-authored-by: CodingWonders <101426328+CodingWonders@users.noreply.github.com> * modified: functions/microwin/Invoke-Microwin.ps1 modified: xaml/inputXML.xaml --------- Co-authored-by: CodingWonders <101426328+CodingWonders@users.noreply.github.com> * Add conversion to ESD (#4) * Add conversion to ESD Issue - #3450 * Update Invoke-Microwin.ps1 Added quotes to the file paths. Put all the arguments in 1 string (as that also works fine) --------- Co-authored-by: CodingWonders <101426328+CodingWonders@users.noreply.github.com> * Update MicroWin contributor list * Merge branch 'main' into microwin-202506 * Merge branch 'main' into microwin-202506 * [MicroWin] Add automatic configuration settings Originally implemented in #2618. Adapted to follow the new file structure. And it works. Though there are issues that will be detailed very soon * [Fix] Fixed typos, updated descriptions * Re-add WinPE driver addition We're not yet sure if that is the actual problem of missing storage controllers. Logs can tell us more about this. Maybe for a future PR? * [Fix/WPBT] Add spaces to reg key path Avoid REG failure * [Fix/XAML] Fix word wrapping issue for checkboxes
2025-08-05 18:24:59 +02:00
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"
}
'@
$firstRun | Out-File -FilePath "$env:temp\FirstStartup.ps1" -Force
}