diff --git a/bucket/7zip.json b/bucket/7zip.json index 85c4260f172b3..9cb421e2b5eae 100644 --- a/bucket/7zip.json +++ b/bucket/7zip.json @@ -1,10 +1,13 @@ { "version": "25.01", - "description": "A multi-format file archiver with high compression ratios", - "homepage": "https://www.7-zip.org/", - "license": "LGPL-2.1-or-later", + "description": "A multi-format file archiver with high compression ratios.", + "homepage": "https://www.7-zip.org", + "license": { + "identifier": "BSD-2-Clause, BSD-3-Clause, LGPL-2.1-or-later", + "url": "https://www.7-zip.org/license.txt" + }, "notes": [ - "Add 7-Zip as a context menu option by running:", + "To register the context menu entry, please execute the following command:", "reg import \"$dir\\install-context.reg\"" ], "architecture": { @@ -30,31 +33,39 @@ } }, "post_install": [ - "$7zip_root = \"$dir\".Replace('\\', '\\\\')", - "'install-context.reg', 'uninstall-context.reg' | ForEach-Object {", - " $content = Get-Content \"$bucketsdir\\main\\scripts\\7-zip\\$_\"", - " $content = $content.Replace('$7zip_root', $7zip_root)", - " if ($global) {", - " $content = $content.Replace('HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE')", - " }", - " Set-Content \"$dir\\$_\" $content -Encoding Ascii", + "$7zip_dir = $dir -replace '\\\\', '\\\\'", + "Get-ChildItem -Path \"$bucketsdir\\$bucket\\scripts\\7-zip\" -Filter '*.reg' -File | ForEach-Object {", + " $content = Get-Content -Path $_.FullName -Encoding utf8", + " if ($global) { $content = $content -replace 'HKEY_CURRENT_USER(?=.+Classes)', 'HKEY_LOCAL_MACHINE' }", + " $content -replace '{{7zip_dir}}', $7zip_dir | Set-Content -Path \"$dir\\$($_.Name)\" -Encoding unicode", "}" ], "bin": [ "7z.exe", - "7zFM.exe", - "7zG.exe" + "7zG.exe", + "7zFM.exe" ], "shortcuts": [ [ "7zFM.exe", - "7-Zip" + "7-Zip\\7-Zip File Manager" + ], + [ + "7-zip.chm", + "7-Zip\\7-Zip Help" ] ], "persist": [ "Codecs", "Formats" ], + "uninstaller": { + "script": [ + "if ($cmd -eq 'uninstall') { reg import \"$dir\\uninstall-context.reg\" *> $null }", + "Stop-Process -Name 'explorer' -Force -ErrorAction SilentlyContinue", + "Start-Sleep -Milliseconds 1500" + ] + }, "checkver": { "url": "https://www.7-zip.org/download.html", "regex": "Download 7-Zip ([\\d.]+) \\(\\d{4}-\\d{2}-\\d{2}\\)" diff --git a/scripts/7-zip/install-context.reg b/scripts/7-zip/install-context.reg index 04858aeafb9d8..a425eef2fe5bf 100644 --- a/scripts/7-zip/install-context.reg +++ b/scripts/7-zip/install-context.reg @@ -1,27 +1,50 @@ Windows Registry Editor Version 5.00 -[HKEY_CURRENT_USER\Software\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}] -@="7-Zip Shell Extension" +; Define per-user configuration parameters for 7-Zip shell integration and UI behavior +; Effective only when configured under the HKEY_CURRENT_USER hive. + +[HKEY_CURRENT_USER\Software\7-Zip\Options] +"CascadedMenu"=dword:00000001 +"MenuIcons"=dword:00000001 + -[HKEY_CURRENT_USER\Software\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32] -@="$7zip_root\\7-zip.dll" -"ThreadingModel"="Apartment" + +; Register 7-Zip as the context menu handler for all files [HKEY_CURRENT_USER\Software\Classes\*\shellex\ContextMenuHandlers\7-Zip] @="{23170F69-40C1-278A-1000-000100020000}" + +; Register 7-Zip as the context menu handler for directory + [HKEY_CURRENT_USER\Software\Classes\Directory\shellex\ContextMenuHandlers\7-Zip] @="{23170F69-40C1-278A-1000-000100020000}" -[HKEY_CURRENT_USER\Software\Classes\Folder\shellex\ContextMenuHandlers\7-Zip] -@="{23170F69-40C1-278A-1000-000100020000}" + +; Register 7-Zip as the drag-and-drop handler for directories [HKEY_CURRENT_USER\Software\Classes\Directory\shellex\DragDropHandlers\7-Zip] @="{23170F69-40C1-278A-1000-000100020000}" + +; Register 7-Zip as the drag-and-drop handler for drives + [HKEY_CURRENT_USER\Software\Classes\Drive\shellex\DragDropHandlers\7-Zip] @="{23170F69-40C1-278A-1000-000100020000}" -[HKEY_CURRENT_USER\SOFTWARE\7-Zip\Options] -"MenuIcons"=dword:00000001 -"CascadedMenu"=dword:00000001 + +; Register 7-Zip as the context menu handler for folder shell objects + +[HKEY_CURRENT_USER\Software\Classes\Folder\shellex\ContextMenuHandlers\7-Zip] +@="{23170F69-40C1-278A-1000-000100020000}" + + + +; Register the CLSID and the in-process COM server DLL for the 7-Zip shell extension + +[HKEY_CURRENT_USER\Software\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}] +@="7-Zip Shell Extension" + +[HKEY_CURRENT_USER\Software\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32] +@="\"{{7zip_dir}}\\7-zip.dll\"" +"ThreadingModel"="Apartment" diff --git a/scripts/7-zip/uninstall-context.reg b/scripts/7-zip/uninstall-context.reg index 79faa9dfc5668..f1fa32c86bb86 100644 --- a/scripts/7-zip/uninstall-context.reg +++ b/scripts/7-zip/uninstall-context.reg @@ -1,10 +1,31 @@ Windows Registry Editor Version 5.00 -[-HKEY_CURRENT_USER\Software\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}] -[-HKEY_CURRENT_USER\Software\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32] +; Unregister all 7-Zip configuration settings and shell integration entries + +[-HKEY_CURRENT_USER\Software\7-Zip] + + +; Unregister the 7-Zip context menu handler for all file types + [-HKEY_CURRENT_USER\Software\Classes\*\shellex\ContextMenuHandlers\7-Zip] + +; Unregister the 7-Zip context menu handler for directories + [-HKEY_CURRENT_USER\Software\Classes\Directory\shellex\ContextMenuHandlers\7-Zip] -[-HKEY_CURRENT_USER\Software\Classes\Folder\shellex\ContextMenuHandlers\7-Zip] + +; Unregister the 7-Zip drag-and-drop handler for directories + [-HKEY_CURRENT_USER\Software\Classes\Directory\shellex\DragDropHandlers\7-Zip] + +; Unregister the 7-Zip drag-and-drop handler for drives + [-HKEY_CURRENT_USER\Software\Classes\Drive\shellex\DragDropHandlers\7-Zip] -[-HKEY_CURRENT_USER\SOFTWARE\7-Zip\Options] + +; Unregister the 7-Zip context menu handler for folder shell objects + +[-HKEY_CURRENT_USER\Software\Classes\Folder\shellex\ContextMenuHandlers\7-Zip] + + +; Unregister the CLSID and the in-process COM server DLL for the 7-Zip shell extension + +[-HKEY_CURRENT_USER\Software\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}]