-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
Issues:
-
The code that first initializes $allApplicationAssociationToasts will cause $allApplicationAssociationToasts to be a string, rather than an array, if the original call returns 1 result. This leads to the resultant buildup of a string, not an array, by the subsequent calls, which isn't right.
-
While fixing this, I rewrote portions of $allApplicationAssociationToasts to be (at least in my opinion) easier to read and troubleshoot. I believe it is functionally identical, however YMMV.
Tested on Powershell 7 w/ StrictMode -Version 3
Submitting my proposed changes back. Sorry that this is just raw code, not a diff. I can convert to diff if desired.
$allApplicationAssociationToasts = @(
Get-Item -Path HKLM:\SOFTWARE\Classes\$Extension\OpenWithList\* -ErrorAction SilentlyContinue | ForEach-Object {
"Applications\$($_.PSChildName)"
})
$allApplicationAssociationToasts += @(
Get-Item -Path HKLM:\SOFTWARE\Classes\$Extension\OpenWithProgids -ErrorAction SilentlyContinue | ForEach-Object {
$_.Property | Where-Object { $_ -and $_ -ne "(default)" }
})
$allApplicationAssociationToasts += @(
Get-Item -Path HKLM:\SOFTWARE\Clients\StartMenuInternet\*\Capabilities\* , HKCU:\SOFTWARE\Clients\StartMenuInternet\*\Capabilities\* -ErrorAction SilentlyContinue | Where-Object { $_.PSChildName -in "URLAssociations", "FileAssociations" } | ForEach-Object {
if ($_.Property -contains $Extension) {
Get-ItemPropertyValue -Path $_.PSPath -Name $Extension
}
})
$allApplicationAssociationToasts | Where-Object { $_ } | ForEach-Object {
if (Set-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts -Name "$($_)_$($Extension)" -Value 0 -Type DWord -ErrorAction SilentlyContinue -PassThru) {
Write-Verbose ("Write Reg ApplicationAssociationToastsList OK: " + $_ + "_" + $Extension)
}
else {
Write-Verbose ("Write Reg ApplicationAssociationToastsList FAILED: " + $_ + "_" + $Extension)
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels