diff --git a/README.md b/README.md index 74288bff8f..645347d811 100644 --- a/README.md +++ b/README.md @@ -472,6 +472,8 @@ Installers and executables are code-signed. The portable zip runs from any folder, a USB stick included. Its `portable.txt` keeps the settings, logs and crash recovery in a `PdfCraftData` folder next to `pdfcraft.exe`, so nothing is written to `%APPDATA%`; delete that file to use the normal per-user folders. +Windows doesn't offer the portable copy as a default PDF app on its own, since it registers nothing; +`portable.txt` has the PowerShell lines that register it for your user only, and how to undo them. The MSI installs for your account only by default, without administrator privileges. Choose "Everyone on this computer" on its first page, or pass `ALLUSERS=1` from an elevated terminal, to install diff --git a/packaging/windows/portable.txt b/packaging/windows/portable.txt index 9586f93060..3890323976 100644 --- a/packaging/windows/portable.txt +++ b/packaging/windows/portable.txt @@ -7,3 +7,41 @@ autosaves and new digital IDs in the PdfCraftData folder beside it, and writes n Delete this file to use the normal per-user folders (%APPDATA%\PdfCraft and %LOCALAPPDATA%\PdfCraft) instead. If PdfCraftData can't be written (for example on a read-only drive), PdfCraft says so and uses the per-user folders instead. + +Opening PDF files with this copy + +The portable copy doesn't register itself with Windows, so picking it under "Open with" may not +stick. To offer it in Settings > Apps > Default apps, open PowerShell in this folder and run: + + $exe = (Resolve-Path .\pdfcraft.exe).Path + $c = "HKCU:\Software\Classes" + $cap = "HKCU:\Software\PdfCraft.Portable\Capabilities" + foreach ($k in "$c\PdfCraft.Portable\shell\open\command", "$c\.pdf\OpenWithProgids", + "$cap\FileAssociations", "HKCU:\Software\RegisteredApplications") { + if (!(Test-Path $k)) { New-Item -Path $k -Force | Out-Null } + } + Set-Item -Path "$c\PdfCraft.Portable" -Value "PDF Document" + Set-Item -Path "$c\PdfCraft.Portable\shell\open\command" -Value "`"$exe`" `"%1`"" + New-ItemProperty -Path "$c\.pdf\OpenWithProgids" -Name PdfCraft.Portable -Value "" -PropertyType String -Force | Out-Null + New-ItemProperty -Path $cap -Name ApplicationName -Value "PdfCraft (portable)" -PropertyType String -Force | Out-Null + New-ItemProperty -Path $cap -Name ApplicationDescription -Value "Open-source PDF workbench" -PropertyType String -Force | Out-Null + New-ItemProperty -Path "$cap\FileAssociations" -Name .pdf -Value PdfCraft.Portable -PropertyType String -Force | Out-Null + New-ItemProperty -Path "HKCU:\Software\RegisteredApplications" -Name "PdfCraft (portable)" -Value "Software\PdfCraft.Portable\Capabilities" -PropertyType String -Force | Out-Null + +Then open Settings > Apps > Default apps, search for .pdf (or for PdfCraft) and choose it. This +changes only your own user's settings (HKEY_CURRENT_USER), and it doesn't change the default app by +itself. If you move or rename this folder, run it again from the new place. + +To undo, first choose another app for .pdf in Settings > Apps > Default apps (otherwise Windows +keeps pointing PDF files at the removed entry), then run: + + Remove-Item -Path "HKCU:\Software\Classes\PdfCraft.Portable", "HKCU:\Software\PdfCraft.Portable" -Recurse -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Classes\.pdf\OpenWithProgids" -Name PdfCraft.Portable -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\RegisteredApplications" -Name "PdfCraft (portable)" -ErrorAction SilentlyContinue + foreach ($k in "HKCU:\Software\Classes\.pdf\OpenWithProgids", "HKCU:\Software\Classes\.pdf") { + $i = Get-Item -Path $k -ErrorAction SilentlyContinue + if ($i -and $i.ValueCount -eq 0 -and $i.SubKeyCount -eq 0) { Remove-Item -Path $k } + } + +The last lines delete the .pdf keys only when nothing else is left in them, so another app's entry +there stays.