7-zip & Windows 7: Make "Extract to <folder>" default on double-click
This thread has become a bit confusing because of contradicting answers (it took me quite some time to figure out which was the right solution) so I thought it might be a good idea to summarize the results from afrazier's and Justin Roettger's posts combinded with my own experiences:
- Start regedit as administrator
- Open
HKEY_CLASSES_ROOT\7-Zip.7z
- Under that key, expand the
Shell
sub-key - Set the
(Default)
value to the stringextract
- Create a new sub-key named
extract
- Set the
(Default)
value for theextract
key toExtract to Folder
- Create a new sub-key under
extract
namedcommand
- Set the
(Default)
value of thecommand
key to:
C:\Program Files\7-Zip\7zG.exe x "%1" -o*
(you might have to adjust this to match the path of your 7-Zip installation)
Instead of 7z with -aou like Justin Roettger suggested I ended up using 7zG, because this way you can choose to overwrite if you like just like extracting with the normal context menu.
That's it! 7z files are now extracted to a folder with their own name by double click. For other extensions like .rar and .zip you need to repeat these steps for the according keys. (i.e. HKEY_CLASSES_ROOT\7-Zip.rar and HKEY_CLASSES_ROOT\7-Zip.zip and so on)
Oh and to clarify: It does work with multiple files selected as well. No batch file need.
The easy way
Install ExtractNow. You can configure it to do exactly what you want.
The hard way
Manual registry modification as follows...
Start
regedit
as administratorOpen
HKCR\.7z
and look at the(Default)
value. Take note of what that is (in my case, as a PowerArchiver user, it'sPASZIP
)Go to the registry key in
HKCR
named that. (in my caseHKCR\PASZIP
)Under that key, expand the
Shell
sub-keySet the
(Default)
value to the stringextract
Create a new sub-key named
extract
Set the
(Default)
value for theextract
key toExtract to Folder
Create a new sub-key under
extract
namedcommand
Set the
(Default)
value of thecommand
key toC:\Program Files\7-Zip\7zG.exe x "%1" -o* -aou
(you might have to adjust the path)
Thanks to Justin Roettger for pointing out the correct name variable needed for this.
That should be it. Now 7z files are extracted to a folder with their own name by double click. For other extensions like .rar and .zip you need to repeat this steps for the according keys.
If you only want to make the changes on your user account instead of system-wide, modify HKCU\Software\Classes
instead of HKCR
. HKCR
is a virtual key that's a union of HKLM\Software\Classes
and HKCU\Software\Classes
where the data in your account (HKCU) overrides the system-wide data (HKLM). Normally running regedit as an Administrator means that modifying HKCR alters system-wide data in HKLM.
Extracting multiple files
Of course, this won't work if you have multiple files selected. If you want that to work, you need to create the following batch file:
@echo off
:top
if "%1"=="" goto :EOF
7z.exe x "%1" -o"%~dpn1"
shift
goto top
Now, follow the instructions above. In the very last step, set the (Default)
value of the command
key to C:\Path\To\File.bat %*
All of the registry modifications are untested from memory, but should be correct.
Unfortunately, afrazier's batch program method won't work; Windows doesn't handle opening multiple files like that. When you try to open multiple files with a program, Windows doesn't open a single instance of the program and pass the files as multiple arguments to that one instance. Instead, Windows opens many instances of the program (as many instances as there are files), passing one file to each instance. It would be nice if you could just use %* and pass a bunch of files to a single .bat, and have that .bat run a loop processing each file one at a time, but unfortunately you can only use %1 when setting these kinds of actions in the registry.
Someone with some time on their hands could write a program that uses a mutex object to check if there is another instance already running, and if there is, to pass it's file to that instance and then close, whereon the original instance will put that file in a queue and get to it once it's done processing its own file. a batch could do the trick using tasklist
and find
, too, but that's not as good of a solution as mutex.
Anyway, try this for your extract command registry value to get the right folder name:
"\path\to\7z.exe" x "%1" -o* -aou
This will create a new folder in the same directory as the source archive with the same name as the source archive (sans the file extension).
Also, I added the -aou
switch to automatically avoid filename conflicts (7z will append a number to the end of a file instead prompting you whether you want to overwrite or whatever).