Files
PowerToys/tools/Verification scripts/Check preview handler registration.ps1

79 lines
3.0 KiB
PowerShell
Raw Permalink Normal View History

#Requires -Version 7.2
using namespace System.Management.Automation
[CmdletBinding()]
param()
function PublicStaticVoidMain {
[CmdletBinding()]
param ()
class TypeHandlerData {
[String] $Name
[String] $CurrentUserHandler
[String] $MachineWideHandler
}
Adds BgcodeThumbnailProvider and BgcodePreviewHandler (#38667) <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [X] **Closes:** #30352 - [X] **Communication:** I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected - [X] **Tests:** Added/updated and all pass - [X] **Localization:** All end user facing strings can be localized - [ ] **Dev docs:** Added/updated - [X] **New binaries:** Added on the required places - [X] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [X] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments ![image](https://github.com/user-attachments/assets/62c0cbbb-fbca-4bb3-82fe-696ba40da83d) ![image](https://github.com/user-attachments/assets/3f2f1346-91fb-4f49-85b9-8cd6e19e68e9) <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed - Close PowerToys if installed in your machine - Full build the solution: PowerToys.sln - Start PowerToys from PowerToys\x64\Debug\PowerToys.exe or PowerToys\x64\Release\PowerToys.exe - Toggle the "Binary G-code thumbnail previewer" setting to enable - Open HelperFiles folder on the tests and check if the icon changes to an image - Check explorer preview to see if image is also shown there --------- Co-authored-by: leileizhang <leilzh@microsoft.com>
2025-07-10 10:20:30 +01:00
[String[]]$TypesToCheck = @(".markdown", ".mdtext", ".mdtxt", ".mdown", ".mkdn", ".mdwn", ".mkd", ".md", ".svg", ".svgz", ".pdf", ".gcode", ".bgcode", ".stl", ".txt", ".ini", ".qoi")
$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"
Adds BgcodeThumbnailProvider and BgcodePreviewHandler (#38667) <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [X] **Closes:** #30352 - [X] **Communication:** I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected - [X] **Tests:** Added/updated and all pass - [X] **Localization:** All end user facing strings can be localized - [ ] **Dev docs:** Added/updated - [X] **New binaries:** Added on the required places - [X] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [X] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments ![image](https://github.com/user-attachments/assets/62c0cbbb-fbca-4bb3-82fe-696ba40da83d) ![image](https://github.com/user-attachments/assets/3f2f1346-91fb-4f49-85b9-8cd6e19e68e9) <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed - Close PowerToys if installed in your machine - Full build the solution: PowerToys.sln - Start PowerToys from PowerToys\x64\Debug\PowerToys.exe or PowerToys\x64\Release\PowerToys.exe - Toggle the "Binary G-code thumbnail previewer" setting to enable - Open HelperFiles folder on the tests and check if the icon changes to an image - Check explorer preview to see if image is also shown there --------- Co-authored-by: leileizhang <leilzh@microsoft.com>
2025-07-10 10:20:30 +01:00
'{dd8de316-7b01-48e7-ba21-e92c646704af}' = "PowerToys BGCode handler"
'{8AA07897-C30B-4543-865B-00A0E5A1B32D}' = "PowerToys QOI 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