Skip to content

Commit

Permalink
fix(HKCU scripts): more checks
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Oct 9, 2024
1 parent 3ff023a commit 1205d6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/playbook/Executables/STARTMENU.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ foreach ($userKey in (Get-RegUserPaths).PsPath) {
$appData = if ($default) {
Get-UserPath -Folder 'F1B32785-6FBA-4FCF-9D55-7B8E7F157091'
} else {
Get-ItemPropertyValue "$userKey\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" -Name 'Local AppData' -EA 0
(Get-ItemProperty "$userKey\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" -Name 'Local AppData' -EA 0).'Local AppData'
}

Write-Title "Configuring Start Menu for '$sid'..."
if (!(Test-Path $appData)) {
if ([string]::IsNullOrEmpty($appData) -or !(Test-Path $appData)) {
Write-Error "Couldn't find AppData value for $sid!"
} else {
Write-Output "Copying default layout XML"
Expand All @@ -31,10 +31,12 @@ foreach ($userKey in (Get-RegUserPaths).PsPath) {
}
}

Write-Output "Clearing default 'tilegrid'"
$tilegrid = Get-ChildItem -Path "$userKey\SOFTWARE\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount" -Recurse | Where-Object { $_.Name -match "start.tilegrid" }
foreach ($key in $tilegrid) {
Remove-Item -Path $key.PSPath -Force
if (!$default) {
Write-Output "Clearing default 'tilegrid'"
$tilegrid = Get-ChildItem -Path "$userKey\SOFTWARE\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount" -Recurse | Where-Object { $_.Name -match "start.tilegrid" }
foreach ($key in $tilegrid) {
Remove-Item -Path $key.PSPath -Force
}
}

Write-Output "Removing advertisements/stubs from Start Menu (23H2+)"
Expand Down
4 changes: 2 additions & 2 deletions src/playbook/Executables/TASKBARPINS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ $taskBarLocation = 'Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
$rootKey = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband'

# Clearing taskbar, copying the shortcut, setting registry
foreach ($userKey in (Get-RegUserPaths).PsPath) {
foreach ($userKey in (Get-RegUserPaths -NoDefault).PsPath) {
$sid = Split-Path $userKey -Leaf
$appData = Get-ItemPropertyValue "$userKey\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" -Name 'AppData' -EA 0

if (!(Test-Path $appData)) {
if ([string]::IsNullOrEmpty($appData) -or !(Test-Path $appData)) {
Write-Error "Couldn't find AppData value for $sid!"
} else {
Write-Title "Setting '$Browser' taskbar shortcut for '$sid'..."
Expand Down

0 comments on commit 1205d6c

Please sign in to comment.