2026-07-11 20:04:51 +02:00
<#
. SYNOPSIS
Restarts Windows Explorer to apply system changes.
2026-06-07 22:51:01 +02:00
2026-07-11 20:04:51 +02:00
. DESCRIPTION
Restarts the Explorer process to ensure all UI modifications take effect. Shows a warning if any of the applied features require a reboot to take full effect.
#>
2026-07-19 22:06:07 +02:00
function Invoke-RestartExplorer {
2026-06-22 02:30:31 +07:00
if ( $script:Params . ContainsKey ( "WhatIf" )) {
Write-Host "[WhatIf] Restart the Windows Explorer process" -ForegroundColor Cyan
return
}
2026-03-07 20:28:48 +01:00
Write-Host "> Attempting to restart the Windows Explorer process to apply all changes..."
2026-06-07 22:51:01 +02:00
if ( $script:Params . ContainsKey ( "NoRestartExplorer" )) {
2026-03-07 20:28:48 +01:00
Write-Host "Explorer process restart was skipped, please manually reboot your PC to apply all changes" -ForegroundColor Yellow
return
}
2026-07-11 20:04:51 +02:00
$rebootFeatures = Get-RebootFeatureLabels
foreach ( $displayLabel in $rebootFeatures ) {
Write-Host "Warning: ' $displayLabel ' requires a reboot to take full effect" -ForegroundColor Yellow
2026-03-07 20:28:48 +01:00
}
# Only restart if the powershell process matches the OS architecture.
# Restarting explorer from a 32bit PowerShell window will fail on a 64bit OS
if ([ Environment ]:: Is64BitProcess -eq [ Environment ]:: Is64BitOperatingSystem ) {
Write-Host "Restarting the Windows Explorer process... (This may cause your screen to flicker)"
Stop-Process -processName: Explorer -Force
}
else {
Write-Host "Unable to restart Windows Explorer process, please manually reboot your PC to apply all changes" -ForegroundColor Yellow
}
2026-07-19 22:06:07 +02:00
}