-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCustomize-Taskbar.ps1
152 lines (141 loc) · 7.62 KB
/
Customize-Taskbar.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<#
Customize Taskbar in Windows 11
Sassan Fanai / Jörgen Nilsson
Version 1.0
#>
param (
[switch]$RemoveTaskView,
[switch]$RemoveWidgets,
[switch]$RemoveChat,
[switch]$MoveStartLeft,
[switch]$RemoveSearch,
[switch]$StartMorePins,
[switch]$StartMoreRecommendations,
[switch]$RunForExistingUsers
)
. $PSScriptRoot\functions.ps1
[string]$RegName = "CustomizeTaskbar"
[string]$FullRegKeyName = "HKLM:\SOFTWARE\ccmexec\"
Set-RegistryKeyValue -Path $FullRegKeyName -Name $RegName -Value "1"
REG LOAD HKLM\Default C:\Users\Default\NTUSER.DAT
switch ($PSBoundParameters.Keys) {
# Removes Task View from the Taskbar
'RemoveTaskView' {
Write-Host "Attempting to run: $PSItem"
$reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Value "0" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
}
# Removes Widgets from the Taskbar
'RemoveWidgets' {
Write-Host "Attempting to run: $PSItem"
$reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarDa" -Value "0" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
}
# Removes Chat from the Taskbar
'RemoveChat' {
Write-Host "Attempting to run: $PSItem"
$reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarMn" -Value "0" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
}
# Default StartMenu alignment 0=Left
'MoveStartLeft' {
Write-Host "Attempting to run: $PSItem"
$reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAl" -Value "0" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
}
# Default StartMenu pins layout 0=Default, 1=More Pins, 2=More Recommendations (requires Windows 11 22H2)
'StartMorePins' {
Write-Host "Attempting to run: $PSItem"
$reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value "1" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
}
# Default StartMenu pins layout 0=Default, 1=More Pins, 2=More Recommendations (requires Windows 11 22H2)
'StartMoreRecommendations' {
Write-Host "Attempting to run: $PSItem"
$reg = New-ItemProperty "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value "2" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
} # Removes search from the Taskbar
'RemoveSearch' {
Write-Host "Attempting to run: $PSItem"
$RegKey = "HKLM:\Default\Software\Microsoft\Windows\CurrentVersion\Search"
if (-not(Test-Path $RegKey )) {
$reg = New-Item $RegKey -Force | Out-Null
try { $reg.Handle.Close() } catch {}
}
$reg = New-ItemProperty $RegKey -Name "SearchboxTaskbarMode" -Value "0" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
}
Default { 'No parameters were specified' }
}
[GC]::Collect()
REG UNLOAD HKLM\Default
if ($PSBoundParameters.ContainsKey('RunForExistingUsers')) {
Write-Host "RunForExistingUsers parameter specified."
$UserProfiles = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*" |
Where-Object { $_.PSChildName -match "S-1-(\d+-?){6}$" } |
Select-Object @{Name = "SID"; Expression = { $_.PSChildName } }, @{Name = "UserHive"; Expression = { "$($_.ProfileImagePath)\NTuser.dat" } }
# Loop through each profile on the machine
foreach ($UserProfile in $UserProfiles) {
Write-Host "Running for profile: $($UserProfile.UserHive)"
# Load User NTUser.dat if it's not already loaded
if (($ProfileWasLoaded = Test-Path Registry::HKEY_USERS\$($UserProfile.SID)) -eq $false) {
Start-Process -FilePath "CMD.EXE" -ArgumentList "/C REG.EXE LOAD HKU\$($UserProfile.SID) $($UserProfile.UserHive)" -Wait -WindowStyle Hidden
}
switch ($PSBoundParameters.Keys) {
# Removes Task View from the Taskbar
'RemoveTaskView' {
Write-Host "Attempting to run: $PSItem"
$reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Value "0" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
}
# Removes Widgets from the Taskbar
'RemoveWidgets' {
Write-Host "Attempting to run: $PSItem"
$reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarDa" -Value "0" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
}
# Removes Chat from the Taskbar
'RemoveChat' {
Write-Host "Attempting to run: $PSItem"
$reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarMn" -Value "0" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
}
# Default StartMenu alignment 0=Left
'MoveStartLeft' {
Write-Host "Attempting to run: $PSItem"
$reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAl" -Value "0" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
}
# Default StartMenu pins layout 0=Default, 1=More Pins, 2=More Recommendations (requires Windows 11 22H2)
'StartMorePins' {
Write-Host "Attempting to run: $PSItem"
$reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value "1" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
}
# Default StartMenu pins layout 0=Default, 1=More Pins, 2=More Recommendations (requires Windows 11 22H2)
'StartMoreRecommendations' {
Write-Host "Attempting to run: $PSItem"
$reg = New-ItemProperty "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value "2" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
}
# Removes search from the Taskbar
'RemoveSearch' {
Write-Host "Attempting to run: $PSItem"
$RegKey = "registry::HKEY_USERS\$($UserProfile.SID)\Software\Microsoft\Windows\CurrentVersion\Search"
if (-not(Test-Path $RegKey )) {
$reg = New-Item $RegKey -Force | Out-Null
try { $reg.Handle.Close() } catch {}
}
$reg = New-ItemProperty $RegKey -Name "SearchboxTaskbarMode" -Value "0" -PropertyType Dword -Force
try { $reg.Handle.Close() } catch {}
}
Default { 'No parameters were specified' }
}
# Unload NTUser.dat
if ($ProfileWasLoaded -eq $false) {
[GC]::Collect()
Start-Sleep 1
Start-Process -FilePath "CMD.EXE" -ArgumentList "/C REG.EXE UNLOAD HKU\$($UserProfile.SID)" -Wait -WindowStyle Hidden
}
}
}