Windows – 7-zip & Windows 7: Make “Extract to ” default on double-click

7-zipwindows 7

I'm trying to find a way to make the action you can perform from the context menu, "Extract to <folder_same_as_file_name>" the default action when double-clicking the file instead of simply launching 7-zip. Is there a simple way to do this?

In the alternative, I gather I could try passing parameters into the following:

7z x <filename> -o<filename>

But I'm not sure how to set this up (how to pass the filename parameter, and can I do this directly or will I have to write a batch file instead and pass the filename to it? The latter I find irritatingly unelegant, but whatever works.

Best Answer

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