Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions bucket/7zip.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we always uninstall the association and stop the explorer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uninstall the association

The context menu is unregistered only when $cmd is set to uninstall. The logic may need to be adjusted when no_junction is true, but since most manifests do not account for this case, I do not believe a change is necessary at this time.

stop the explorer

Because 7-Zip uses CLSIDs when registering context menu entries, updates or uninstalls may fail due to files being in use if explorer is not stopped. As most users who install 7-Zip are likely to enable the context menu integration, I believe it is unnecessary to explicitly check whether the context menu is registered, and stopping explorer directly is sufficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, if the user has registered file associations, uninstalling via Scoop does not currently remove the associated settings. Should .reg files be provided to manage and clean up file associations?

"Start-Sleep -Milliseconds 1500"
]
},
"checkver": {
"url": "https://www.7-zip.org/download.html",
"regex": "Download 7-Zip ([\\d.]+) \\(\\d{4}-\\d{2}-\\d{2}\\)"
Expand Down
43 changes: 33 additions & 10 deletions scripts/7-zip/install-context.reg
Original file line number Diff line number Diff line change
@@ -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"
29 changes: 25 additions & 4 deletions scripts/7-zip/uninstall-context.reg
Original file line number Diff line number Diff line change
@@ -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}]