mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-10-08 11:39:10 +11:00
* Fix WaaSMedicSvc restoration using direct registry write Set-Service fails on WaaSMedicSvc with Access Denied since it's a protected service (LaunchProtected=2). FirstLogon.ps1 silently swallowed this failure via -ErrorAction SilentlyContinue, permanently leaving WaaSMedicSvc disabled after setup. Removes WaaSMedicSvc from the Set-Service restoration loop and restores it via a direct registry write instead, matching the same technique already used to disable it in WinUtil-PostInstall.ps1. Added a test verifying the old Set-Service-based restoration is gone and the new registry-write fix is present. Addresses the WaaSMedicSvc portion of #5095; the broader AppX/Store failure investigation is out of scope for this change. * Assert exact registry-write contract for WaaSMedicSvc test Per CodeRabbit review: the previous assertion only checked that Set-ItemProperty and WaaSMedicSvc appeared near each other, which would pass even with a wrong -Value or -Type. Now asserts the complete command including -Value 3 and -Type DWord. * Surface service restoration failures in FirstLogon.log BITS, wuauserv, UsoSvc, and WaaSMedicSvc restoration all used -ErrorAction SilentlyContinue, which suppresses errors before they reach the output stream FirstLogon.ps1 redirects to its log file (*>&1 ... >> FirstLogon.log). This meant any restoration failure — not just the WaaSMedicSvc one already fixed — was invisible even in the log. Changed -ErrorAction SilentlyContinue to Continue on both the Set-Service loop and the WaaSMedicSvc registry write, so failures still don't halt the script but now actually land in FirstLogon.log for troubleshooting. Addresses the logging portion of the reporter's suggestion in #5095. * Assert -ErrorAction Continue in WaaSMedicSvc test Per CodeRabbit review: the existing test only checked the Set-ItemProperty command and value, not the -ErrorAction Continue change made for logging. Extended the same test to also assert both the Set-ItemProperty and Set-Service lines use Continue instead of SilentlyContinue. * Extend WaaSMedicSvc test to cover full ErrorAction Continue Per CodeRabbit review: the registry-write assertion stopped at -Type DWord, so a regression back to -ErrorAction SilentlyContinue would still pass. Extended the pattern to include -ErrorAction Continue at the end of the command. * Exercise FirstLogon service restoration behavior --------- Co-authored-by: Chris Titus <contact@christitus.com>
524 lines
28 KiB
XML
524 lines
28 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
|
|
<!--https://schneegans.de/windows/unattend-generator/?LanguageMode=Interactive&ProcessorArchitecture=amd64&BypassRequirementsCheck=true&ComputerNameMode=Random&CompactOsMode=Default&TimeZoneMode=Implicit&PartitionMode=Interactive&DiskAssertionMode=Skip&WindowsEditionMode=Interactive&InstallFromMode=Automatic&PEMode=Default&UserAccountMode=InteractiveLocal&PasswordExpirationMode=Unlimited&LockoutMode=Default&HideFiles=Hidden&ClassicContextMenu=true&LaunchToThisPC=true&ShowEndTask=true&TaskbarSearch=Hide&TaskbarIconsMode=Empty&DisableWidgets=true&LeftTaskbar=true&HideTaskViewButton=true&StartTilesMode=Default&StartPinsMode=Empty&EnableLongPaths=true&HideEdgeFre=true&DisableEdgeStartupBoost=true&DeleteWindowsOld=true&EffectsMode=Default&DeleteEdgeDesktopIcon=true&DesktopIconsMode=Default&StartFoldersMode=Default&WifiMode=Skip&ExpressSettings=DisableAll&LockKeysMode=Configure&CapsLockInitial=Off&CapsLockBehavior=Toggle&NumLockInitial=On&NumLockBehavior=Toggle&ScrollLockInitial=Off&ScrollLockBehavior=Toggle&StickyKeysMode=Disabled&ColorMode=Custom&SystemColorTheme=Dark&AppsColorTheme=Dark&AccentColor=%230078d4&WallpaperMode=Default&LockScreenMode=Default&WdacMode=Skip&AppLockerMode=Skip-->
|
|
<settings pass="offlineServicing"></settings>
|
|
<settings pass="windowsPE">
|
|
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
|
|
<UserData>
|
|
<AcceptEula>true</AcceptEula>
|
|
</UserData>
|
|
<UseConfigurationSet>false</UseConfigurationSet>
|
|
<RunSynchronous>
|
|
<RunSynchronousCommand wcm:action="add">
|
|
<Order>1</Order>
|
|
<Path>reg.exe add "HKLM\SYSTEM\Setup\LabConfig" /v BypassTPMCheck /t REG_DWORD /d 1 /f</Path>
|
|
</RunSynchronousCommand>
|
|
<RunSynchronousCommand wcm:action="add">
|
|
<Order>2</Order>
|
|
<Path>reg.exe add "HKLM\SYSTEM\Setup\LabConfig" /v BypassSecureBootCheck /t REG_DWORD /d 1 /f</Path>
|
|
</RunSynchronousCommand>
|
|
<RunSynchronousCommand wcm:action="add">
|
|
<Order>3</Order>
|
|
<Path>reg.exe add "HKLM\SYSTEM\Setup\LabConfig" /v BypassRAMCheck /t REG_DWORD /d 1 /f</Path>
|
|
</RunSynchronousCommand>
|
|
<RunSynchronousCommand wcm:action="add">
|
|
<Order>4</Order>
|
|
<Path>reg.exe add "HKLM\SYSTEM\Setup\LabConfig" /v BypassCPUCheck /t REG_DWORD /d 1 /f</Path>
|
|
</RunSynchronousCommand>
|
|
<RunSynchronousCommand wcm:action="add">
|
|
<Order>5</Order>
|
|
<Path>reg.exe add "HKLM\SYSTEM\Setup\LabConfig" /v BypassStorageCheck /t REG_DWORD /d 1 /f</Path>
|
|
</RunSynchronousCommand>
|
|
</RunSynchronous>
|
|
</component>
|
|
</settings>
|
|
<settings pass="generalize"></settings>
|
|
<settings pass="specialize">
|
|
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
|
|
<RunSynchronous>
|
|
<RunSynchronousCommand wcm:action="add">
|
|
<Order>1</Order>
|
|
<Path>powershell.exe -WindowStyle "Normal" -NoProfile -Command "$xml = [xml]::new(); $xml.Load('C:\Windows\Panther\unattend.xml'); $sb = [scriptblock]::Create( $xml.unattend.Extensions.ExtractScript ); Invoke-Command -ScriptBlock $sb -ArgumentList $xml;"</Path>
|
|
</RunSynchronousCommand>
|
|
<RunSynchronousCommand wcm:action="add">
|
|
<Order>2</Order>
|
|
<Path>powershell.exe -WindowStyle "Normal" -ExecutionPolicy "Unrestricted" -NoProfile -File "C:\Windows\Setup\Scripts\Specialize.ps1"</Path>
|
|
</RunSynchronousCommand>
|
|
<RunSynchronousCommand wcm:action="add">
|
|
<Order>3</Order>
|
|
<Path>reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT"</Path>
|
|
</RunSynchronousCommand>
|
|
<RunSynchronousCommand wcm:action="add">
|
|
<Order>4</Order>
|
|
<Path>powershell.exe -WindowStyle "Normal" -ExecutionPolicy "Unrestricted" -NoProfile -File "C:\Windows\Setup\Scripts\DefaultUser.ps1"</Path>
|
|
</RunSynchronousCommand>
|
|
<RunSynchronousCommand wcm:action="add">
|
|
<Order>5</Order>
|
|
<Path>reg.exe unload "HKU\DefaultUser"</Path>
|
|
</RunSynchronousCommand>
|
|
<RunSynchronousCommand wcm:action="add">
|
|
<Order>6</Order>
|
|
<Path>reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OOBE" /v BypassNRO /t REG_DWORD /d 1 /f</Path>
|
|
</RunSynchronousCommand>
|
|
<RunSynchronousCommand wcm:action="add">
|
|
<Order>7</Order>
|
|
<Path>reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\BitLocker" /v PreventDeviceEncryption /t REG_DWORD /d 1 /f</Path>
|
|
</RunSynchronousCommand>
|
|
<RunSynchronousCommand wcm:action="add">
|
|
<Order>8</Order>
|
|
<Path>reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" /v ShippedWithReserves /t REG_DWORD /d 0 /f</Path>
|
|
</RunSynchronousCommand>
|
|
</RunSynchronous>
|
|
</component>
|
|
</settings>
|
|
<settings pass="auditSystem"></settings>
|
|
<settings pass="auditUser"></settings>
|
|
<settings pass="oobeSystem">
|
|
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
|
|
<OOBE>
|
|
<ProtectYourPC>3</ProtectYourPC>
|
|
<HideEULAPage>true</HideEULAPage>
|
|
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
|
|
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
|
|
</OOBE>
|
|
<FirstLogonCommands>
|
|
<SynchronousCommand wcm:action="add">
|
|
<Order>1</Order>
|
|
<CommandLine>powershell.exe -WindowStyle "Normal" -ExecutionPolicy "Unrestricted" -NoProfile -File "C:\Windows\Setup\Scripts\FirstLogon.ps1"</CommandLine>
|
|
</SynchronousCommand>
|
|
</FirstLogonCommands>
|
|
</component>
|
|
</settings>
|
|
<Extensions xmlns="https://schneegans.de/windows/unattend-generator/">
|
|
<ExtractScript>
|
|
param(
|
|
[xml]$Document
|
|
);
|
|
|
|
foreach( $file in $Document.unattend.Extensions.File ) {
|
|
$path = [System.Environment]::ExpandEnvironmentVariables( $file.GetAttribute( 'path' ) );
|
|
mkdir -Path( $path | Split-Path -Parent ) -ErrorAction 'SilentlyContinue';
|
|
$encoding = switch( [System.IO.Path]::GetExtension( $path ) ) {
|
|
{ $_ -in '.ps1', '.xml' } { [System.Text.Encoding]::UTF8; }
|
|
{ $_ -in '.reg', '.vbs', '.js' } { [System.Text.UnicodeEncoding]::new( $false, $true ); }
|
|
default { [System.Text.Encoding]::Default; }
|
|
};
|
|
$bytes = $encoding.GetPreamble() + $encoding.GetBytes( $file.InnerText.Trim() );
|
|
[System.IO.File]::WriteAllBytes( $path, $bytes );
|
|
}
|
|
</ExtractScript>
|
|
<File path="C:\Windows\Setup\Scripts\TaskbarLayoutModification.xml">
|
|
<LayoutModificationTemplate xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification" xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" xmlns:taskbar="http://schemas.microsoft.com/Start/2014/TaskbarLayout" Version="1">
|
|
<CustomTaskbarLayoutCollection PinListPlacement="Replace">
|
|
<defaultlayout:TaskbarLayout>
|
|
<taskbar:TaskbarPinList>
|
|
<taskbar:DesktopApp DesktopApplicationLinkPath="#leaveempty" />
|
|
</taskbar:TaskbarPinList>
|
|
</defaultlayout:TaskbarLayout>
|
|
</CustomTaskbarLayoutCollection>
|
|
</LayoutModificationTemplate>
|
|
</File>
|
|
<File path="C:\Windows\Setup\Scripts\UnlockStartLayout.vbs">
|
|
HKU = &H80000003
|
|
Set reg = GetObject("winmgmts://./root/default:StdRegProv")
|
|
Set fso = CreateObject("Scripting.FileSystemObject")
|
|
|
|
If reg.EnumKey(HKU, "", sids) = 0 Then
|
|
If Not IsNull(sids) Then
|
|
For Each sid In sids
|
|
key = sid + "\Software\Policies\Microsoft\Windows\Explorer"
|
|
name = "LockedStartLayout"
|
|
If reg.GetDWORDValue(HKU, key, name, existing) = 0 Then
|
|
reg.SetDWORDValue HKU, key, name, 0
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
</File>
|
|
<File path="C:\Windows\Setup\Scripts\UnlockStartLayout.xml">
|
|
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
<Triggers>
|
|
<EventTrigger>
|
|
<Enabled>true</Enabled>
|
|
<Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="Application"&gt;&lt;Select Path="Application"&gt;*[System[Provider[@Name='UnattendGenerator'] and EventID=1]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
|
|
</EventTrigger>
|
|
</Triggers>
|
|
<Principals>
|
|
<Principal id="Author">
|
|
<UserId>S-1-5-18</UserId>
|
|
<RunLevel>LeastPrivilege</RunLevel>
|
|
</Principal>
|
|
</Principals>
|
|
<Settings>
|
|
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
|
|
<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
|
|
<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
|
|
<AllowHardTerminate>true</AllowHardTerminate>
|
|
<StartWhenAvailable>false</StartWhenAvailable>
|
|
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
|
|
<IdleSettings>
|
|
<StopOnIdleEnd>true</StopOnIdleEnd>
|
|
<RestartOnIdle>false</RestartOnIdle>
|
|
</IdleSettings>
|
|
<AllowStartOnDemand>true</AllowStartOnDemand>
|
|
<Enabled>true</Enabled>
|
|
<Hidden>false</Hidden>
|
|
<RunOnlyIfIdle>false</RunOnlyIfIdle>
|
|
<WakeToRun>false</WakeToRun>
|
|
<ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
|
|
<Priority>7</Priority>
|
|
</Settings>
|
|
<Actions Context="Author">
|
|
<Exec>
|
|
<Command>C:\Windows\System32\wscript.exe</Command>
|
|
<Arguments>C:\Windows\Setup\Scripts\UnlockStartLayout.vbs</Arguments>
|
|
</Exec>
|
|
</Actions>
|
|
</Task>
|
|
</File>
|
|
<File path="C:\Windows\Setup\Scripts\SetStartPins.ps1">
|
|
$json = '{"pinnedList":[]}';
|
|
if( [System.Environment]::OSVersion.Version.Build -lt 20000 ) {
|
|
return;
|
|
}
|
|
$key = 'Registry::HKLM\SOFTWARE\Microsoft\PolicyManager\current\device\Start';
|
|
New-Item -Path $key -ItemType 'Directory' -ErrorAction 'SilentlyContinue';
|
|
Set-ItemProperty -LiteralPath $key -Name 'ConfigureStartPins' -Value $json -Type 'String';
|
|
</File>
|
|
<File path="C:\Windows\Setup\Scripts\SetColorTheme.ps1">
|
|
$lightThemeSystem = 0;
|
|
$lightThemeApps = 0;
|
|
$accentColorOnStart = 0;
|
|
$enableTransparency = 0;
|
|
$htmlAccentColor = '#0078D4';
|
|
& {
|
|
$params = @{
|
|
LiteralPath = 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize';
|
|
Force = $true;
|
|
Type = 'DWord';
|
|
};
|
|
Set-ItemProperty @params -Name 'SystemUsesLightTheme' -Value $lightThemeSystem;
|
|
Set-ItemProperty @params -Name 'AppsUseLightTheme' -Value $lightThemeApps;
|
|
Set-ItemProperty @params -Name 'ColorPrevalence' -Value $accentColorOnStart;
|
|
Set-ItemProperty @params -Name 'EnableTransparency' -Value $enableTransparency;
|
|
};
|
|
& {
|
|
Add-Type -AssemblyName 'System.Drawing';
|
|
$accentColor = [System.Drawing.ColorTranslator]::FromHtml( $htmlAccentColor );
|
|
|
|
function ConvertTo-DWord {
|
|
param(
|
|
[System.Drawing.Color]
|
|
$Color
|
|
);
|
|
|
|
[byte[]]$bytes = @(
|
|
$Color.R;
|
|
$Color.G;
|
|
$Color.B;
|
|
$Color.A;
|
|
);
|
|
return [System.BitConverter]::ToUInt32( $bytes, 0);
|
|
}
|
|
|
|
$startColor = [System.Drawing.Color]::FromArgb( 0xD2, $accentColor );
|
|
Set-ItemProperty -LiteralPath 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent' -Name 'StartColorMenu' -Value( ConvertTo-DWord -Color $accentColor ) -Type 'DWord' -Force;
|
|
Set-ItemProperty -LiteralPath 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent' -Name 'AccentColorMenu' -Value( ConvertTo-DWord -Color $accentColor ) -Type 'DWord' -Force;
|
|
Set-ItemProperty -LiteralPath 'Registry::HKCU\Software\Microsoft\Windows\DWM' -Name 'AccentColor' -Value( ConvertTo-DWord -Color $accentColor ) -Type 'DWord' -Force;
|
|
$params = @{
|
|
LiteralPath = 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Accent';
|
|
Name = 'AccentPalette';
|
|
};
|
|
$palette = Get-ItemPropertyValue @params;
|
|
$index = 20;
|
|
$palette[ $index++ ] = $accentColor.R;
|
|
$palette[ $index++ ] = $accentColor.G;
|
|
$palette[ $index++ ] = $accentColor.B;
|
|
$palette[ $index++ ] = $accentColor.A;
|
|
Set-ItemProperty @params -Value $palette -Type 'Binary' -Force;
|
|
};
|
|
</File>
|
|
<File path="C:\Windows\Setup\Scripts\Specialize.ps1">
|
|
$scripts = @(
|
|
{
|
|
reg.exe add "HKLM\SYSTEM\Setup\MoSetup" /v AllowUpgradesWithUnsupportedTPMOrCPU /t REG_DWORD /d 1 /f;
|
|
};
|
|
{
|
|
net.exe accounts /maxpwage:UNLIMITED;
|
|
};
|
|
{
|
|
reg.exe add "HKLM\Software\Policies\Microsoft\Windows\CloudContent" /v "DisableCloudOptimizedContent" /t REG_DWORD /d 1 /f;
|
|
[System.Diagnostics.EventLog]::CreateEventSource( 'UnattendGenerator', 'Application' );
|
|
};
|
|
{
|
|
Register-ScheduledTask -TaskName 'UnlockStartLayout' -Xml $( Get-Content -LiteralPath 'C:\Windows\Setup\Scripts\UnlockStartLayout.xml' -Raw );
|
|
};
|
|
{
|
|
reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f
|
|
};
|
|
{
|
|
Remove-Item -LiteralPath 'C:\Users\Public\Desktop\Microsoft Edge.lnk' -ErrorAction 'SilentlyContinue' -Verbose;
|
|
};
|
|
{
|
|
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Dsh" /v AllowNewsAndInterests /t REG_DWORD /d 0 /f;
|
|
};
|
|
{
|
|
reg.exe add "HKLM\Software\Policies\Microsoft\Edge" /v HideFirstRunExperience /t REG_DWORD /d 1 /f;
|
|
};
|
|
{
|
|
reg.exe add "HKLM\Software\Policies\Microsoft\Edge\Recommended" /v BackgroundModeEnabled /t REG_DWORD /d 0 /f;
|
|
reg.exe add "HKLM\Software\Policies\Microsoft\Edge\Recommended" /v StartupBoostEnabled /t REG_DWORD /d 0 /f;
|
|
};
|
|
{
|
|
& 'C:\Windows\Setup\Scripts\SetStartPins.ps1';
|
|
};
|
|
{
|
|
reg.exe add "HKU\.DEFAULT\Control Panel\Accessibility\StickyKeys" /v Flags /t REG_SZ /d 10 /f;
|
|
};
|
|
{
|
|
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v NoAutoUpdate /t REG_DWORD /d 1 /f;
|
|
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DisableWindowsUpdateAccess /t REG_DWORD /d 1 /f;
|
|
};
|
|
);
|
|
|
|
& {
|
|
[float]$complete = 0;
|
|
[float]$increment = 100 / $scripts.Count;
|
|
foreach( $script in $scripts ) {
|
|
Write-Progress -Id 0 -Activity 'Running scripts to customize your Windows installation. Do not close this window.' -PercentComplete $complete;
|
|
'*** Will now execute command «{0}».' -f $(
|
|
$str = $script.ToString().Trim() -replace '\s+', ' ';
|
|
$max = 100;
|
|
if( $str.Length -le $max ) {
|
|
$str;
|
|
} else {
|
|
$str.Substring( 0, $max - 1 ) + '…';
|
|
}
|
|
);
|
|
$start = [datetime]::Now;
|
|
& $script;
|
|
'*** Finished executing command after {0:0} ms.' -f [datetime]::Now.Subtract( $start ).TotalMilliseconds;
|
|
"`r`n" * 3;
|
|
$complete += $increment;
|
|
}
|
|
} *>&1 | Out-String -Width 1KB -Stream >> "C:\Windows\Setup\Scripts\Specialize.log";
|
|
</File>
|
|
<File path="C:\Windows\Setup\Scripts\UserOnce.ps1">
|
|
$scripts = @(
|
|
{
|
|
[System.Diagnostics.EventLog]::WriteEntry( 'UnattendGenerator', "User '$env:USERNAME' has requested to unlock the Start menu layout.", [System.Diagnostics.EventLogEntryType]::Information, 1 );
|
|
};
|
|
{
|
|
Remove-Item -Path "${env:USERPROFILE}\Desktop\*.lnk" -Force -ErrorAction 'SilentlyContinue';
|
|
Remove-Item -Path "$env:HOMEDRIVE\Users\Default\Desktop\*.lnk" -Force -ErrorAction 'SilentlyContinue';
|
|
};
|
|
{
|
|
$taskbarPath = "$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar";
|
|
if( Test-Path $taskbarPath ) {
|
|
Get-ChildItem -Path $taskbarPath -File | Remove-Item -Force;
|
|
}
|
|
Remove-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband' -Name 'FavoritesRemovedChanges' -Force -ErrorAction 'SilentlyContinue';
|
|
Remove-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband' -Name 'FavoritesChanges' -Force -ErrorAction 'SilentlyContinue';
|
|
Remove-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband' -Name 'Favorites' -Force -ErrorAction 'SilentlyContinue';
|
|
};
|
|
{
|
|
reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /ve /f;
|
|
};
|
|
{
|
|
Set-ItemProperty -LiteralPath 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'LaunchTo' -Type 'DWord' -Value 1;
|
|
};
|
|
{
|
|
Set-ItemProperty -LiteralPath 'Registry::HKCU\Software\Microsoft\Windows\CurrentVersion\Search' -Name 'SearchboxTaskbarMode' -Type 'DWord' -Value 0;
|
|
};
|
|
{
|
|
& 'C:\Windows\Setup\Scripts\SetColorTheme.ps1';
|
|
};
|
|
{
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.Suggested" /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.Suggested" /v Enabled /t REG_DWORD /d 0 /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.StartupApp" /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.StartupApp" /v Enabled /t REG_DWORD /d 0 /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.SkyDrive.Desktop" /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.SkyDrive.Desktop" /v Enabled /t REG_DWORD /d 0 /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.AccountHealth" /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Windows.SystemToast.AccountHealth" /v Enabled /t REG_DWORD /d 0 /f;
|
|
};
|
|
{
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Start" /v AllAppsViewMode /t REG_DWORD /d 2 /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Start_IrisRecommendations /t REG_DWORD /d 0 /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Start_AccountNotifications /t REG_DWORD /d 0 /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Start" /v ShowAllPinsList /t REG_DWORD /d 0 /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Start" /v ShowFrequentList /t REG_DWORD /d 0 /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Start" /v ShowRecentList /t REG_DWORD /d 0 /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v Start_TrackDocs /t REG_DWORD /d 0 /f;
|
|
};
|
|
{
|
|
Restart-Computer -Force;
|
|
};
|
|
);
|
|
|
|
& {
|
|
[float]$complete = 0;
|
|
[float]$increment = 100 / $scripts.Count;
|
|
foreach( $script in $scripts ) {
|
|
Write-Progress -Id 0 -Activity 'Running scripts to configure this user account. Do not close this window.' -PercentComplete $complete;
|
|
'*** Will now execute command «{0}».' -f $(
|
|
$str = $script.ToString().Trim() -replace '\s+', ' ';
|
|
$max = 100;
|
|
if( $str.Length -le $max ) {
|
|
$str;
|
|
} else {
|
|
$str.Substring( 0, $max - 1 ) + '…';
|
|
}
|
|
);
|
|
$start = [datetime]::Now;
|
|
& $script;
|
|
'*** Finished executing command after {0:0} ms.' -f [datetime]::Now.Subtract( $start ).TotalMilliseconds;
|
|
"`r`n" * 3;
|
|
$complete += $increment;
|
|
}
|
|
} *>&1 | Out-String -Width 1KB -Stream >> "$env:TEMP\UserOnce.log";
|
|
</File>
|
|
<File path="C:\Windows\Setup\Scripts\DefaultUser.ps1">
|
|
$scripts = @(
|
|
{
|
|
reg.exe add "HKU\DefaultUser\Software\Policies\Microsoft\Windows\Explorer" /v "StartLayoutFile" /t REG_SZ /d "C:\Windows\Setup\Scripts\TaskbarLayoutModification.xml" /f;
|
|
reg.exe add "HKU\DefaultUser\Software\Policies\Microsoft\Windows\Explorer" /v "LockedStartLayout" /t REG_DWORD /d 1 /f;
|
|
};
|
|
{
|
|
reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ShowTaskViewButton /t REG_DWORD /d 0 /f;
|
|
};
|
|
{
|
|
reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v TaskbarAl /t REG_DWORD /d 0 /f;
|
|
};
|
|
{
|
|
foreach( $root in 'Registry::HKU\.DEFAULT', 'Registry::HKU\DefaultUser' ) {
|
|
Set-ItemProperty -LiteralPath "$root\Control Panel\Keyboard" -Name 'InitialKeyboardIndicators' -Type 'String' -Value 2 -Force;
|
|
}
|
|
};
|
|
{
|
|
reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\TaskbarDeveloperSettings" /v TaskbarEndTask /t REG_DWORD /d 1 /f;
|
|
};
|
|
{
|
|
reg.exe add "HKU\DefaultUser\Control Panel\Accessibility\StickyKeys" /v Flags /t REG_SZ /d 10 /f;
|
|
};
|
|
{
|
|
reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\DWM" /v ColorPrevalence /t REG_DWORD /d 0 /f;
|
|
};
|
|
{
|
|
reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\RunOnce" /v "UnattendedSetup" /t REG_SZ /d "powershell.exe -WindowStyle \""Normal\"" -ExecutionPolicy \""Unrestricted\"" -NoProfile -File \""C:\Windows\Setup\Scripts\UserOnce.ps1\""" /f;
|
|
};
|
|
);
|
|
|
|
& {
|
|
[float]$complete = 0;
|
|
[float]$increment = 100 / $scripts.Count;
|
|
foreach( $script in $scripts ) {
|
|
Write-Progress -Id 0 -Activity 'Running scripts to modify the default user’’s registry hive. Do not close this window.' -PercentComplete $complete;
|
|
'*** Will now execute command «{0}».' -f $(
|
|
$str = $script.ToString().Trim() -replace '\s+', ' ';
|
|
$max = 100;
|
|
if( $str.Length -le $max ) {
|
|
$str;
|
|
} else {
|
|
$str.Substring( 0, $max - 1 ) + '…';
|
|
}
|
|
);
|
|
$start = [datetime]::Now;
|
|
& $script;
|
|
'*** Finished executing command after {0:0} ms.' -f [datetime]::Now.Subtract( $start ).TotalMilliseconds;
|
|
"`r`n" * 3;
|
|
$complete += $increment;
|
|
}
|
|
} *>&1 | Out-String -Width 1KB -Stream >> "C:\Windows\Setup\Scripts\DefaultUser.log";
|
|
</File>
|
|
<File path="C:\Windows\Setup\Scripts\FirstLogon.ps1">
|
|
$scripts = @(
|
|
{
|
|
Remove-Item -LiteralPath @(
|
|
'C:\Windows\Panther\unattend.xml';
|
|
'C:\Windows\Panther\unattend-original.xml';
|
|
'C:\Windows\Setup\Scripts\Wifi.xml';
|
|
'C:\Windows.old';
|
|
) -Recurse -Force -ErrorAction 'SilentlyContinue';
|
|
};
|
|
{
|
|
reg.exe delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v OneDriveSetup /f;
|
|
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v NoAutoUpdate /f;
|
|
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v AUOptions /f;
|
|
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v UseWUServer /f;
|
|
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v DisableWindowsUpdateAccess /f;
|
|
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v WUServer /f;
|
|
reg.exe delete "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" /v WUStatusServer /f;
|
|
reg.exe delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" /v DODownloadMode /f;
|
|
reg.exe add "HKLM\Software\Policies\Microsoft\Windows\OneDrive" /v DisableFileSyncNGSC /t REG_DWORD /d 0 /f;
|
|
reg.exe add "HKCU\Software\Microsoft\Windows\CurrentVersion\GameDVR" /v AppCaptureEnabled /t REG_DWORD /d 0 /f;
|
|
$services = @{ BITS = 'Manual'; wuauserv = 'Manual'; UsoSvc = 'Automatic' };
|
|
foreach ($name in $services.Keys) {
|
|
Set-Service -Name $name -StartupType $services[$name] -ErrorAction Continue;
|
|
}
|
|
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc' -Name 'Start' -Value 3 -Type DWord -ErrorAction Continue;
|
|
};
|
|
{
|
|
reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\current\device\Education" /f;
|
|
reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\current\device\Start" /f;
|
|
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\Explorer" /f;
|
|
reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\current\device\Education" /v IsEducationEnvironment /t REG_DWORD /d 1 /f;
|
|
reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows\Explorer" /v HideRecommendedSection /t REG_DWORD /d 1 /f;
|
|
reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\current\device\Start" /v HideRecommendedSection /t REG_DWORD /d 1 /f;
|
|
};
|
|
{
|
|
$recallFeature = Get-WindowsOptionalFeature -Online -ErrorAction SilentlyContinue | Where-Object { $_.State -eq 'Enabled' -and $_.FeatureName -like 'Recall' };
|
|
if( $recallFeature ) {
|
|
Disable-WindowsOptionalFeature -Online -FeatureName 'Recall' -Remove -ErrorAction SilentlyContinue;
|
|
}
|
|
};
|
|
{
|
|
$viveDir = Join-Path $env:TEMP 'ViVeTool';
|
|
$viveZip = Join-Path $env:TEMP 'ViVeTool.zip';
|
|
Invoke-WebRequest 'https://github.com/thebookisclosed/ViVe/releases/download/v0.3.4/ViVeTool-v0.3.4-IntelAmd.zip' -OutFile $viveZip;
|
|
Expand-Archive -Path $viveZip -DestinationPath $viveDir -Force;
|
|
Remove-Item -Path $viveZip -Force;
|
|
Start-Process -FilePath (Join-Path $viveDir 'ViVeTool.exe') -ArgumentList '/disable /id:47205210' -Wait -NoNewWindow;
|
|
Remove-Item -Path $viveDir -Recurse -Force;
|
|
};
|
|
{
|
|
Start-Process C:\Windows\System32\OneDriveSetup.exe -ArgumentList /uninstall
|
|
};
|
|
{
|
|
if( (Get-BitLockerVolume -MountPoint $Env:SystemDrive).ProtectionStatus -eq 'On' ) {
|
|
Disable-BitLocker -MountPoint $Env:SystemDrive;
|
|
}
|
|
};
|
|
{
|
|
if( (bcdedit | Select-String 'path').Count -eq 2 ) {
|
|
bcdedit /set `{bootmgr`} timeout 0;
|
|
}
|
|
};
|
|
);
|
|
|
|
& {
|
|
[float]$complete = 0;
|
|
[float]$increment = 100 / $scripts.Count;
|
|
foreach( $script in $scripts ) {
|
|
Write-Progress -Id 0 -Activity 'Running scripts to finalize your Windows installation. Do not close this window.' -PercentComplete $complete;
|
|
'*** Will now execute command «{0}».' -f $(
|
|
$str = $script.ToString().Trim() -replace '\s+', ' ';
|
|
$max = 100;
|
|
if( $str.Length -le $max ) {
|
|
$str;
|
|
} else {
|
|
$str.Substring( 0, $max - 1 ) + '…';
|
|
}
|
|
);
|
|
$start = [datetime]::Now;
|
|
& $script;
|
|
'*** Finished executing command after {0:0} ms.' -f [datetime]::Now.Subtract( $start ).TotalMilliseconds;
|
|
"`r`n" * 3;
|
|
$complete += $increment;
|
|
}
|
|
} *>&1 | Out-String -Width 1KB -Stream >> "C:\Windows\Setup\Scripts\FirstLogon.log";
|
|
</File>
|
|
</Extensions>
|
|
</unattend>
|