# Set Explorer Quick Access Toolbar Items
# Make a copy of the following registry entry before running this script
# HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Ribbon
# change the order of the lines to change the order the tools are displayed
# delete or comment-out tools you do not want
# uncomment the tools you want
$tools =
@(
#16128, # Undo
#16129, # Redo
#12352, # Delete to trashcan
12384, # Properties
12336, # New Folder
#12357, # Rename
12301, # Open PowerShell Here
12303, # Open PowerShell As Administrator Here
#12290, # Open Command Prompt Here (disabled in v1704)
#12291, # Open Command Prompt As Administrator Here (disabled in v1704)
12289, # Open New Explorer Window
12403, # Invert Selection
12324, # Copy Path
#13651, # Manage Computer
#12354, # Peranently Delete
#16482, # Change Explorer Options
0 # useful so list can be resorted without needing to changing commas on last one
)
# Explorer default toolset - needed to prevent crashing, don't edit
$defaultTools = @( 16128, 16129, 12352, 12384, 12336, 12357 )
# for safety, die if any error encountered
$ErrorActionPreference = "Stop"
# read binary XML from registry
$qatBinary = (Get-ItemProperty HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Ribbon -Name QatItems).QatItems
# convert into xml
[xml]$xml = [Text.Encoding]::ASCII.GetString($qatBinary)
# save a copy of the current setup
$xml.save("previous explorer qat.xml")
#exit
# find controls node
$sharedControls = $xml.CustomUI.ribbon.qat.sharedControls
$controls = $sharedControls.control
# make a clone of first tool item (this should never be empty)
$item = $controls[0].Clone()
# clear tool list
$sharedControls.RemoveAll()
# to prevent explorer from crashing, we need to explicitly add any standard items we aren't using
$item.visible = "false"
$item.argument = "0"
foreach ($tool in $defaultTools)
{
# skip items we are going to add
if ($tools.Contains($tool)) { continue }
$newItem = $item.Clone()
$newItem.idQ = "siq:$tool"
$sharedControls.AppendChild($newItem) | Out-Null
}
# now add the tools we want in the order we want
$item.visible = "true"
$item.argument = "0"
foreach ($tool in $tools)
{
if ($tool -le 0) { break }
$newItem = $item.Clone()
$newItem.idQ = "siq:$tool"
$sharedControls.AppendChild($newItem) | Out-Null
}
# convert XML back into binary sequence
$qatBinary = [Text.Encoding]::ASCII.GetBytes($xml.OuterXml)
# write binary XML back into registry
New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Ribbon -Name "QatItems" -PropertyType BINARY -Force -Value $qatBinary | Out-Null
Comments