Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: WinZip Command Line with php

1. ## WinZip Command Line with php

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?

http://www.winzip.com/wzcline.htm

• On what kind of server shall that work? I guess Windows IIS?

Why don't you use the standard zip extension instead? As an alternative, you can use the Archive_Tar package from PEAR.

• I dont know why you have to know the server? I just want to know how to use the command line in php script?

• Maybe due to the fact winzip is made for windows?

• Originally Posted by romram
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, especially at the functions called exec and system. There are plenty of examples in the user comments on these manual pages.

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

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

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???

• 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

• I see the files in the command window, but I don't see the folder were the zipped file is extracted to.

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

• 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...?

Code:
<?PHP
$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>"; system($cmd,$return); echo 'done. <BR>'; } else return "File$source Not Found!<br>";
}

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

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

PHP Code:
 <? exec("C:\PROGRA~1\winzip\wzunzip -yb C:\\MyFile.zip C:\\",$return); print_r($return); ?> 

• 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?

• We tried this command in Dos window and it worked fine but in PHP code it hangs
Code:
<?PHP
system('"c:\\program files\\winzip\\wzunzip" -d -o C:\\sokkit\\site\\s.zip');
?>

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•