w10install/scripts/cleanup-tiles.ps1
Michael H.G. Schmidt de9700e31f .
2021-01-10 18:45:55 +01:00

64 lines
2.4 KiB
PowerShell

#
# this script loads a tile layout for the
# start menu with NO tiles at all!
# ( = deletes all tiles )
#
$LAYOUT='C:\Windows\StartLayout.xml'
write-host '#######',(split-path $PSCommandPath -Leaf),'#######'
echo "delete layout file if it already exists ..."
If(Test-Path $LAYOUT) {
Remove-Item $LAYOUT
}
echo "create a blank layout file [ $LAYOUT ] ..."
echo "<LayoutModificationTemplate xmlns:defaultlayout=""http://schemas.microsoft.com/Start/2014/FullDefaultLayout"" xmlns:start=""http://schemas.microsoft.com/Start/2014/StartLayout"" Version=""1"" xmlns=""http://schemas.microsoft.com/Start/2014/LayoutModification"">" > $LAYOUT
echo " <LayoutOptions StartTileGroupCellWidth=""6"" />" >> $LAYOUT
echo " <DefaultLayoutOverride>" >> $LAYOUT
echo " <StartLayoutCollection>" >> $LAYOUT
echo " <defaultlayout:StartLayout GroupCellWidth=""6"" />" >> $LAYOUT
echo " </StartLayoutCollection>" >> $LAYOUT
echo " </DefaultLayoutOverride>" >> $LAYOUT
echo "</LayoutModificationTemplate>" >> $LAYOUT
$regAliases = @("HKLM", "HKCU")
# assign the start layout and force it to apply with
# "LockedStartLayout" at both the machine and user level ...
echo "assign the start layout AND apply it ..."
foreach ($regAlias in $regAliases) {
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
IF(!(Test-Path -Path $keyPath)) {
New-Item -Path $basePath -Name "Explorer"
}
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 1
Set-ItemProperty -Path $keyPath -Name "StartLayoutFile" -Value "$LAYOUT"
}
# restart Explorer, open the start menu (necessary to load the new layout),
# and give it a few seconds to process ...
Start-Sleep -s 3
echo "restart explorer ..."
Stop-Process -name explorer
Start-Sleep -s 3
$wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('^{ESCAPE}')
Start-Sleep -s 3
# enable the ability to pin items again by disabling "LockedStartLayout" ...
foreach ($regAlias in $regAliases) {
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 0
}
# restart Explorer and delete the layout file ...
echo "restart explorer ..."
Stop-Process -name explorer
Remove-Item $LAYOUT
write-host '#######',(split-path $PSCommandPath -Leaf),'#######'