From ef657fa1ce89ff821c29befceb10ce512878e164 Mon Sep 17 00:00:00 2001 From: Fabio Ribeiro Date: Mon, 18 Oct 2021 22:31:59 +0200 Subject: [PATCH] 7-zip: script to install explorer context menu --- bucket/7zip.json | 36 +++++++++++++++++++++++++---- scripts/7-zip/install-context.reg | 21 +++++++++++++++++ scripts/7-zip/uninstall-context.reg | 8 +++++++ 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 scripts/7-zip/install-context.reg create mode 100644 scripts/7-zip/uninstall-context.reg diff --git a/bucket/7zip.json b/bucket/7zip.json index e851c083b03050..e2766a74b1d018 100644 --- a/bucket/7zip.json +++ b/bucket/7zip.json @@ -6,16 +6,44 @@ "identifier": "Freeware,LGPL-2.0-only,BSD-3-Clause", "url": "https://www.7-zip.org/license.txt" }, + "notes": "Add 7-Zip as a context menu option by running: \"$dir\\install-7zip.reg\"", "architecture": { "64bit": { - "url": "https://7-zip.org/a/7z1900-x64.msi", - "hash": "a7803233eedb6a4b59b3024ccf9292a6fffb94507dc998aa67c5b745d197a5dc" + "url": [ + "https://7-zip.org/a/7z1900-x64.msi", + "https://raw.githubusercontent.com/ScoopInstaller/Main/master/scripts/7-zip/install-context.reg", + "https://raw.githubusercontent.com/ScoopInstaller/Main/master/scripts/7-zip/uninstall-context.reg" + ], + "hash": [ + "a7803233eedb6a4b59b3024ccf9292a6fffb94507dc998aa67c5b745d197a5dc", + "358c8a2f87c4dc89c86ee4c72c71766856da146c0a8840001e6821fe5bb0c7ca", + "667ef7b5c7bfb6cdcc595042ac6c0cae802fbfd59fc601b22b533f6f1bcaf374" + ] }, "32bit": { - "url": "https://7-zip.org/a/7z1900.msi", - "hash": "b49d55a52bc0eab14947c8982c413d9be141c337da1368a24aa0484cbb5e89cd" + "url": [ + "https://7-zip.org/a/7z1900.msi", + "https://raw.githubusercontent.com/ScoopInstaller/Main/master/scripts/7-zip/install-context.reg", + "https://raw.githubusercontent.com/ScoopInstaller/Main/master/scripts/7-zip/uninstall-context.reg" + ], + "hash": [ + "b49d55a52bc0eab14947c8982c413d9be141c337da1368a24aa0484cbb5e89cd", + "358c8a2f87c4dc89c86ee4c72c71766856da146c0a8840001e6821fe5bb0c7ca", + "667ef7b5c7bfb6cdcc595042ac6c0cae802fbfd59fc601b22b533f6f1bcaf374" + ] } }, + "pre_install": [ + "$7zip_root = \"$dir\".Replace('\\', '\\\\')", + "'install-7zip.reg', 'uninstall-7zip.reg' | ForEach-Object {", + " $content = Get-Content \"$dir\\$_\"", + " $content = $content.Replace('$7zip_root', $7zip_root)", + " if ($global) {", + " $content = $content.Replace('HKEY_CURRENT_USER', 'HKEY_LOCAL_MACHINE')", + " }", + " Set-Content \"$dir\\$_\" $content -Encoding Ascii", + "}" + ], "extract_dir": "Files\\7-Zip", "bin": "7z.exe", "shortcuts": [ diff --git a/scripts/7-zip/install-context.reg b/scripts/7-zip/install-context.reg new file mode 100644 index 00000000000000..9b245f97b77e68 --- /dev/null +++ b/scripts/7-zip/install-context.reg @@ -0,0 +1,21 @@ +Windows Registry Editor Version 5.00 + +[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_root\\7-zip.dll" +"ThreadingModel"="Apartment" + +[HKEY_CURRENT_USER\Software\Classes\*\shellex\ContextMenuHandlers\7-Zip] +@="{23170F69-40C1-278A-1000-000100020000}" + +[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}" + +[HKEY_CURRENT_USER\SOFTWARE\7-Zip\Options] +"MenuIcons"=dword:00000001 +"CascadedMenu"=dword:00000001 diff --git a/scripts/7-zip/uninstall-context.reg b/scripts/7-zip/uninstall-context.reg new file mode 100644 index 00000000000000..70e7390c849f7d --- /dev/null +++ b/scripts/7-zip/uninstall-context.reg @@ -0,0 +1,8 @@ +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] +[-HKEY_CURRENT_USER\Software\Classes\*\shellex\ContextMenuHandlers\7-Zip] +[-HKEY_CURRENT_USER\Software\Classes\Directory\shellex\ContextMenuHandlers\7-Zip] +[-HKEY_CURRENT_USER\Software\Classes\Folder\shellex\ContextMenuHandlers\7-Zip] +[-HKEY_CURRENT_USER\SOFTWARE\7-Zip\Options]