View Full Version : WinZip Command Line with php

04-18-2004, 07:28 PM
Please do somebody know how to use "WinZip Command Line support Add-on" with php, how to writ a script that will extract zipped files using this facility?

please check this link:

04-18-2004, 08:14 PM
On what kind of server shall that work? I guess Windows IIS?

Why don't you use the standard zip extension (http://www.php.net/manual/en/ref.zip.php) instead? As an alternative, you can use the Archive_Tar (http://pear.php.net/package/Archive_Tar) package from PEAR.

04-18-2004, 08:24 PM
I dont know why you have to know the server? I just want to know how to use the command line in php script?

04-18-2004, 09:36 PM
Maybe due to the fact winzip is made for windows?

04-18-2004, 11:49 PM
I dont know why you have to know the server?

Trust me, it's important information when you want to execute a program from the shell through PHP. So, is your server running on windows? If not, you can forget calling the winzip through the command line.

I'm still baffled why you didn't answer directly that fairly simple question.

I just want to know how to use the command line in php script?

Have a look at the Program Execution Functions (http://www.php.net/manual/en/ref.exec.php), especially at the functions called exec (http://www.php.net/manual/en/function.exec.php) and system (http://www.php.net/manual/en/function.system.php). There are plenty of examples in the user comments on these manual pages.

04-25-2004, 10:37 AM
Hi mordred...
it is very late, but I will tell now all the information:

Platform: Windows 2000 professional
php version:4.3.3
server:Apache 2.0

Note: I don't know how to use the command line, because I am of that generation that when his eyes opened there was only buttons and clicks... :rolleyes:

04-26-2004, 08:34 AM
I used the command line like this and I get an error massege:

C:\>"c:\program files\winzip\wzzip" -v MyFile.zip
WinZip(R) Command Line Support Add-On Version 1.1 (Build 6028)
Copyright (c) WinZip Computing, Inc. 1991-2004 - All Rights Reserved

ERROR: Zip file MyFile.zip does not exist
Program is terminating!

I wrote the command in this way and I got the following massege:

C:\>wzzip -v MyFile.zip
'wzzip' is not recognized as an internal or external command,
operable program or batch file.

What happen ?? Does anybody know??? :confused: :confused: :(

04-26-2004, 09:55 AM
C:\>"c:\program files\winzip\wzzip" -v c:\path\to\MyFile.zip

unless MyFile.zip is in c:\MyFile.zip , still easier to use the path anyway

04-26-2004, 10:13 PM
I see the files in the command window, but I don't see the folder were the zipped file is extracted to.

04-27-2004, 04:36 AM
-v is probably the 'view/verbose' flag e.g. showing the contents of the zipfile (or teeling you what is being done) , there will be other flags for extraction, compression etc , read the docs for a list of command flags.

04-27-2004, 09:31 AM
I used the following code to unzip files using winzip command line, the command worked in the command window, but it didn't work in the code, it says that the file is unzipped but I can't see any thing...?

$root ='c:\\';
$unzipcmd = 'c:\>"c:\\program files\\winzip\\wzunzip" -d';

function unzip($source,$target) {
global $unzipcmd;
if (file_exists($source)) {
echo "unzipping $source to $target . . .<br>";
$cmd = $unzipcmd.' '.$source.' '.$target;
echo $cmd."<br>";
echo 'done. <BR>';
else return "File $source Not Found!<br>";

echo "<pre>".unzip($root."MyFile.zip","c:\\")."</pre>";
echo $root."<BR>";

04-27-2004, 12:48 PM
Hi , your exec command should look something like below ..

however the unregistered/evaluation version of winzip ignores the -yb flag and requires user input , e.g you will note that from the command line you have to 'press any key' , I tried to reproduce this via popen && proc_open etc but with no joy (on windows XP)

exec("C:\PROGRA~1\winzip\wzunzip -yb C:\\MyFile.zip C:\\",$return);

04-27-2004, 05:22 PM
It worked now, but it worked once and then when try it another time the browser hangs?
it seems that the system cll taked a long time to excuete? is there any solution? :(

05-08-2004, 10:29 AM
We tried this command in Dos window and it worked fine but in PHP code it hangs

system('"c:\\program files\\winzip\\wzunzip" -d -o C:\\sokkit\\site\\s.zip');