7-zip & Windows 7: Make "Extract to <folder>" default on double-click

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).


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:

  1. Start regedit as administrator
  2. Open HKEY_CLASSES_ROOT\7-Zip.7z
  3. Under that key, expand the Shell sub-key
  4. Set the (Default) value to the string extract
  5. Create a new sub-key named extract
  6. Set the (Default) value for the extract key to Extract to Folder
  7. Create a new sub-key under extract named command
  8. Set the (Default) value of the command 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.