mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-05 04:39:08 +08:00
05d5649c9c
* Register .markdown with the correct handler * Fix spelling * Move file name extensions from "expect.txt" to "excludes.txt" * Revert "Move file name extensions from "expect.txt" to "excludes.txt"" This reverts commit710d5a4968
. I must have misunderstood the instructions. * Revert "Register .markdown with the correct handler" This reverts commit5c37b009f3
. * Work in progress * Code ready for testing * Update excludes.txt * Update excludes.txt * Update modulesRegistry.h * Update modulesRegistry.h For the want of an exclamation mark, a kingdom is lost! * Update modulesRegistry.h * Work on modulesRegistry.h per code review in 16180 Removed all previous exclusions from Monaco preview handler. Added a new exclusion: SVGZ. It's a binary file that Monaco cannot, in any meaningful way, read. * Update expect.txt * Update accessory files * Disable machine-wide checks for performance reasons
77 lines
2.8 KiB
PowerShell
77 lines
2.8 KiB
PowerShell
#Requires -Version 7.2
|
|
|
|
using namespace System.Management.Automation
|
|
|
|
[CmdletBinding()]
|
|
param()
|
|
|
|
function PublicStaticVoidMain {
|
|
[CmdletBinding()]
|
|
param ()
|
|
|
|
class TypeHandlerData {
|
|
[String] $Name
|
|
[String] $CurrentUserHandler
|
|
[String] $MachineWideHandler
|
|
}
|
|
|
|
[String[]]$TypesToCheck = @(".markdown", ".mdtext", ".mdtxt", ".mdown", ".mkdn", ".mdwn", ".mkd", ".md", ".svg", ".svgz", ".pdf", ".gcode", ".stl", ".txt", ".ini")
|
|
$IPREVIEW_HANDLER_CLSID = '{8895b1c6-b41f-4c1c-a562-0d564250836f}'
|
|
$PowerToysHandlers = @{
|
|
'{07665729-6243-4746-95b7-79579308d1b2}' = "PowerToys PDF handler"
|
|
'{ddee2b8a-6807-48a6-bb20-2338174ff779}' = "PowerToys SVG handler"
|
|
'{ec52dea8-7c9f-4130-a77b-1737d0418507}' = "PowerToys GCode handler"
|
|
'{45769bcc-e8fd-42d0-947e-02beef77a1f5}' = "PowerToys Markdown handler"
|
|
'{afbd5a44-2520-4ae0-9224-6cfce8fe4400}' = "PowerToys Monaco fallback handler"
|
|
'{DC6EFB56-9CFA-464D-8880-44885D7DC193}' = "Adobe Acrobat DC"
|
|
}
|
|
|
|
function ResolveHandlerGUIDtoName {
|
|
param (
|
|
[Parameter(Mandatory, Position = 0)]
|
|
[String] $GUID
|
|
)
|
|
return $PowerToysHandlers[$GUID] ?? $GUID
|
|
}
|
|
|
|
function WriteMyProgress {
|
|
param (
|
|
[Parameter(Mandatory, Position=0)] [Int32] $ItemsPending,
|
|
[Parameter(Mandatory, Position=1)] [Int32] $ItemsTotal,
|
|
[switch] $Completed
|
|
)
|
|
[Int32] $PercentComplete = ($ItemsPending / $ItemsTotal) * 100
|
|
if ($PercentComplete -lt 1) { $PercentComplete = 1}
|
|
Write-Progress -Activity 'Querying Windows Registry' -Status "$ItemsPending of $ItemsTotal" -PercentComplete $PercentComplete -Completed:$Completed
|
|
}
|
|
|
|
$ItemsTotal = $TypesToCheck.Count * 2
|
|
$ItemsPending = 0
|
|
WriteMyProgress 0 $ItemsTotal
|
|
|
|
$CheckResults = New-Object -TypeName 'System.Collections.Generic.List[TypeHandlerData]'
|
|
foreach ($item in $TypesToCheck) {
|
|
$CurrentUserGUID = Get-ItemPropertyValue -Path "HKCU://Software/Classes/$item/shellex/$IPREVIEW_HANDLER_CLSID" -Name '(default)' -ErrorAction SilentlyContinue
|
|
$ItemsPending += 1
|
|
WriteMyProgress $ItemsPending $ItemsTotal
|
|
|
|
$MachineWideGUID = "Didn't check"
|
|
# $MachineWideGUID = Get-ItemPropertyValue -Path "HKLM://Software/Classes/$item/shellex/$IPREVIEW_HANDLER_CLSID" -Name '(default)' -ErrorAction SilentlyContinue
|
|
$ItemsPending += 1
|
|
WriteMyProgress $ItemsPending $ItemsTotal
|
|
|
|
$temp = New-Object -TypeName TypeHandlerData -Property @{
|
|
Name = $item
|
|
CurrentUserHandler = ($null -eq $CurrentUserGUID) ? "Nothing" : (ResolveHandlerGUIDtoName ($CurrentUserGUID))
|
|
MachineWideHandler = ($null -eq $MachineWideGUID) ? "Nothing" : (ResolveHandlerGUIDtoName ($MachineWideGUID))
|
|
}
|
|
$CheckResults.Add($temp)
|
|
|
|
Clear-Variable 'CurrentUserGUID', 'MachineWideGUID'
|
|
}
|
|
WriteMyProgress $ItemsPending $ItemsTotal -Completed
|
|
$CheckResults | Format-Table -AutoSize
|
|
}
|
|
|
|
PublicStaticVoidMain
|