You are here

Using 7-Zip Portable from the command line

4 posts / 0 new
Last post
Murple
Offline
Last seen: 15 years 9 months ago
Joined: 2005-12-10 10:26
Using 7-Zip Portable from the command line

Hey,

I'm working on a simple script to let me drop various archive files on to a small GUI to automatically decompress the archive and -if the decompression was successful- delete the original archive. Since I would like my script to be portable I've been trying to use 7za.exe, the help file explains:

"7za.exe (a = alone) is a standalone version of 7-Zip. 7za.exe supports only 7z, cab, zip, gzip, bzip2, Z and tar formats"

Compared to the following formats which are supported by the installed version of 7-Zip: "7z, zip, gz, gzip, tgz, bz2, bzip2, tbz2, tbz, tar, rar, cab, arj, z, taz, cpio, rpm, deb, lzh, lha, chw, hxs, msi".

The same help file explains:
"7z.exe is the command line version of 7-Zip. 7z.exe uses 7z.dll from the 7-Zip package. 7z.dll is used by the 7-Zip File Manager also."

So I tried copying 7z.exe and 7z.dll from the portableapps version and call the 7Z.exe from my script, but have not managed to get this to work either. My question is therefore:

Is there a way to run the portableapps version of 7Zip from the command line so that all of the file formats supported by the standard installation of the program can be extracted? Any other recommendations?

I hope I made myself understood and hope for some positive replies!

Regards,
Murple

rab040ma
Offline
Last seen: 3 months 1 week ago
Joined: 2007-08-27 13:35
Are you saying that 7z.exe

Are you saying that 7z.exe doesn't work at all? Or that it doesn't work with specific archives? Are there any error messages?

In general, all you have to do is make sure the DLL is on the PATH. The easiest way to do that is to concatenate the directory that contains it (e.g. x:\PortableApps\7-ZipPortable\App\7-Zip) to the rest of the PATH variable's contents.

What language are you using for your script? We could probably point you to samples of how to do that.

MC

Murple
Offline
Last seen: 15 years 9 months ago
Joined: 2005-12-10 10:26
Thanks for the quick reply.

Thanks for the quick reply. To be able to answer your questions, I had to do some more testing and when I moved my script to the "x:\PortableApps\7-ZipPortable\App\7-Zip" folder things started to work with the 7Z.exe. I'm a little confused as to what you mean by the PATH (Surely not the Windows environment PATH?)?

I'm using AutoHotkey, I just posted my script to the AHK forums here:
http://www.autohotkey.com/forum/viewtopic.php?t=39513

I'm still curious as to which files I actually need (e.g. 7z.exe and 7z.dll) so that my script can extract all of the formats supported by the "full version" of 7-Zip and how to use them. Ideally I would like to include a handful of files and distribute those together with my script.

rab040ma
Offline
Last seen: 3 months 1 week ago
Joined: 2007-08-27 13:35
Yes, the Windows Environment

Yes, the Windows Environment PATH.

The Windows environment is available to all programs. If you type in a program's name (e.g. 7z.exe) without a path, or try to launch a shortcut set up that way, Windows first looks for that program in the current directory, then in each path in the PATH environment variable until it finds it. When 7z.exe in turn asks windows to load 7z.dll, Windows looks in the current directory, then in each directory on the PATH. (That's why it worked when your current directory was App\7-Zip.) I'm not sure exactly why 7z.exe doesn't tell Windows to look in the directory where it found 7z.exe, but that's a different question. The question you are asking is "how to get 7z.exe to load the dll" and the answer is "make sure 7z.dll is on the PATH". Blum

It looks like the EnvAdd command is what you want in AHK. To make sure you don't break things, you want to add the path to 7z.dll to the existing PATH. I'd put it at the beginning, but it doesn't matter much.

Note that when you change the PATH this way, it should only change it for the sub-process that runs 7z.exe, not for every other process on the computer. Environment variables are inherited from a program's parent, and a program with a different parent will normally have a different PATH.

MC

Log in or register to post comments