Skip to content

Commit 0509b71

Browse files
committed
fix: possible fix for the corrupted taskbar "file" issue by making sure it makes a FOLDER not a FILE
1 parent 0f0533c commit 0509b71

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

src/playbook/Executables/AtlasModules/Scripts/taskbarPins.ps1

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ foreach ($entry in $regTaskbar.GetEnumerator()) {
9494
$taskBarLocation = 'Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar'
9595
$rootKey = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband'
9696

97+
Stop-Process -Name explorer -Force -ErrorAction SilentlyContinue
98+
Start-Sleep -Milliseconds 500
99+
97100
# Clearing taskbar, copying the shortcut, setting registry
98101
foreach ($userKey in (Get-RegUserPaths -NoDefault).PsPath) {
99102
$sid = Split-Path $userKey -Leaf
@@ -108,13 +111,19 @@ foreach ($userKey in (Get-RegUserPaths -NoDefault).PsPath) {
108111
Write-Output "Clearing current shortcuts..."
109112
$taskBarAppData = "$appData\$taskBarLocation"
110113
if (Test-Path $taskBarAppData -PathType Leaf) {
111-
Write-Output "Deleting TaskBar file..."
114+
Write-Output "Deleting corrupted TaskBar file..."
112115
Remove-Item -Path $taskBarAppData -Force
113116
}
114-
Get-ChildItem $taskBarAppData | Remove-Item -Force -Recurse
117+
if (!(Test-Path $taskBarAppData -PathType Container)) {
118+
Write-Output "Creating TaskBar folder..."
119+
New-Item -Path $taskBarAppData -ItemType Directory -Force | Out-Null
120+
} else {
121+
Get-ChildItem $taskBarAppData | Remove-Item -Force -Recurse
122+
}
115123

116124
Write-Output "Adding new shortcuts..."
117-
Copy-Item -Path "$tmp\*" -Destination $taskBarAppData -Force
125+
# make sure its a folder with a backslash
126+
Copy-Item -Path "$tmp\*" -Destination "$taskBarAppData\" -Force
118127

119128
Write-Output "Changing in Registry..."
120129
$key = "$(Convert-Path $userKey)\$rootKey"
@@ -124,4 +133,4 @@ foreach ($userKey in (Get-RegUserPaths -NoDefault).PsPath) {
124133
}
125134
}
126135

127-
Stop-Process -Name explorer -Force
136+
Stop-Process -Name explorer -Force -ErrorAction SilentlyContinue

src/playbook/Executables/TASKBARPINS.ps1

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ foreach ($entry in $regTaskbar.GetEnumerator()) {
8484
$taskBarLocation = 'Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar'
8585
$rootKey = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband'
8686

87+
Stop-Process -Name explorer -Force -ErrorAction SilentlyContinue
88+
Start-Sleep -Milliseconds 500
89+
8790
# Clearing taskbar, copying the shortcut, setting registry
8891
foreach ($userKey in (Get-RegUserPaths -NoDefault).PsPath) {
8992
$sid = Split-Path $userKey -Leaf
@@ -93,17 +96,22 @@ foreach ($userKey in (Get-RegUserPaths -NoDefault).PsPath) {
9396
Write-Error "Couldn't find AppData value for $sid!"
9497
} else {
9598
Write-Title "Setting '$Browser' taskbar shortcut for '$sid'..."
96-
9799
Write-Output "Clearing current shortcuts..."
98100
$taskBarAppData = "$appData\$taskBarLocation"
99101
if (Test-Path $taskBarAppData -PathType Leaf) {
100-
Write-Output "Deleting TaskBar file..."
102+
Write-Output "Deleting corrupted TaskBar file..."
101103
Remove-Item -Path $taskBarAppData -Force
102104
}
103-
Get-ChildItem $taskBarAppData | Remove-Item -Force -Recurse
105+
if (!(Test-Path $taskBarAppData -PathType Container)) {
106+
Write-Output "Creating TaskBar folder..."
107+
New-Item -Path $taskBarAppData -ItemType Directory -Force | Out-Null
108+
} else {
109+
Get-ChildItem $taskBarAppData | Remove-Item -Force -Recurse
110+
}
104111

105112
Write-Output "Adding new shortcuts..."
106-
Copy-Item -Path "$tmp\*" -Destination $taskBarAppData -Force
113+
# make sure its a folder with a backslash
114+
Copy-Item -Path "$tmp\*" -Destination "$taskBarAppData\" -Force
107115

108116
Write-Output "Changing in Registry..."
109117
$key = "$(Convert-Path $userKey)\$rootKey"
@@ -112,4 +120,5 @@ foreach ($userKey in (Get-RegUserPaths -NoDefault).PsPath) {
112120
}
113121
}
114122
}
115-
Stop-Process -Name explorer -Force
123+
124+
Stop-Process -Name explorer -Force -ErrorAction SilentlyContinue

0 commit comments

Comments
 (0)