diff --git a/scripts/cleanup-tiles.cmd b/scripts/cleanup-tiles.cmd deleted file mode 100644 index 2015946..0000000 --- a/scripts/cleanup-tiles.cmd +++ /dev/null @@ -1,10 +0,0 @@ -@echo off - -echo ####### %0 ####### - -echo starting powershell script ... -powershell -command .\cleanup-tiles.ps1 -echo. - -echo ####### %0 ####### - diff --git a/scripts/cleanup-tiles.ps1 b/scripts/cleanup-tiles.ps1 index c59694c..a8391b6 100644 --- a/scripts/cleanup-tiles.ps1 +++ b/scripts/cleanup-tiles.ps1 @@ -1,66 +1,57 @@ -# -# this script loads a tile layout for the -# start menu with NO tiles at all! -# ( = deletes all tiles ) -# +#Requires -RunAsAdministrator -$LAYOUT='C:\Windows\StartLayout.xml' +$START_MENU_LAYOUT = @" + + + + + + + + +"@ -write-host '#######',(split-path $PSCommandPath -Leaf),'#######' +$layoutFile="C:\Windows\StartMenuLayout.xml" -echo "delete layout file if it already exists ..." -If(Test-Path $LAYOUT) { - Remove-Item $LAYOUT +#Delete layout file if it already exists +If(Test-Path $layoutFile) +{ + Remove-Item $layoutFile } -echo "create a blank layout file [ $LAYOUT ] ..." -echo "" > $LAYOUT -echo " " >> $LAYOUT -echo " " >> $LAYOUT -echo " " >> $LAYOUT -echo " " >> $LAYOUT -echo " " >> $LAYOUT -echo " " >> $LAYOUT -echo "" >> $LAYOUT +#Creates the blank layout file +$START_MENU_LAYOUT | Out-File $layoutFile -Encoding ASCII $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" +#Assign the start layout and force it to apply with "LockedStartLayout" at both the machine and user level +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 $layoutFile } -# restart Explorer, open the start menu (necessary to load the new layout), -# and give it a few seconds to process ... -echo "restart explorer ..." -taskkill /F /IM explorer.exe -sleep 3 -start explorer.exe -sleep 3 +#Restart Explorer, open the start menu (necessary to load the new layout), and give it a few seconds to process +Stop-Process -name explorer +Start-Sleep -s 5 $wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('^{ESCAPE}') -sleep 3 +Start-Sleep -s 5 -# 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 +#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 ..." -taskkill /F /IM explorer.exe -sleep 3 -Remove-Item $LAYOUT -start explorer.exe +#Restart Explorer and delete the layout file +Stop-Process -name explorer -write-host '#######',(split-path $PSCommandPath -Leaf),'#######' +# Uncomment the next line to make clean start menu default for all new users +Import-StartLayout -LayoutPath $layoutFile -MountPath $env:SystemDrive\ +Remove-Item $layoutFile