Link to home
Start Free TrialLog in
Avatar of jrbbldr
jrbbldr

asked on

Winrar - Command line to create ZIP Format

As far as I can tell I am currently using Winrar 3.62 on my Win XP Pro workstation
And with that version the interactive GUI allows me to designate a ZIP format output - and it works.

But I have been trying to run Winrar through the Command Line.
I can get an archive file successfully created, but when I attempt to open it with something else like WinZip, I get an error telling me that the file is not in a valid format.

I am guessing that regardless of the output file extension that I have designated, I am really getting a .RAR file which just happens to have a .ZIP extension.

I have found various Winrar command option references on the web to end up with a valid ZIP format archive file.
    -afzip
    -zip
None have resulted in a file which can be un-zipped with WinZip, but they do extract through WinRAR

Currently I am trying the following:
   C:\PROGRA~1\WINRAR\RAR.EXE a -zip "C:\Temp\ChkZip.zip" "C:\Temp\Temp*.dbf"

Any advice on how to correct my command line so as to get a valid ZIP Format archive file would be greatly appreciated.

Thanks

ASKER CERTIFIED SOLUTION
Avatar of cheers4beers
cheers4beers
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jrbbldr
jrbbldr

ASKER

Thank you for the quick reply.

I followed your advice and modified the command line.
I changed from RAR.EXE to WinRAR.EXE   and I changed from   -Zip to  -AFZip

Those changes resulted in the following command line:
 C:\PROGRA~1\WINRAR\WinRAR.EXE a -afzip "C:\Temp\ChkZip.zip" "C:\Temp\Temp*.dbf"

The above command line ran fine in the DOS Command window and created the output file   ChkZip.zip  as intended from the specified files.  I watched it run.

However, once again, when I attempt to open the file with WinZip, it gives me an "invalid format" error message.

The reason I need to check that the file can open correctly with WinZip is that I am sending the ZIP file to another vendor and they need it in a 'true' ZIP Format.    Running the Create Archive in the WinRar Windows GUI for a Zip formatted file works just fine.

Any other suggestions?

Thanks
Avatar of jrbbldr

ASKER

New development.

Apparently I forgot that I had one other option within the string that I executed for testing and it did not appear above - the    -ep    option

I removed that and I got an Archive file created which did indeed open correctly with WinZip.

Now the next associated question is, if I run the Command Line within my application, will it run synchronously or asynchronously?

I'd like it to run in synchronous mode so that I will 'know' when it is complete and my application can then go on to use the resultant archive file.   Yes, I can have my application go into a wait mode until the archive file 'appears' in the directory, but, if possible with option settings, I'd rather wait.

Any advice?

Thanks
SOLUTION
Avatar of BillDL
BillDL
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jrbbldr

ASKER

The command line for WinRAR worked well.

As to getting things to work synchronously, I decided to just run a routine to check if WinRAR was still running and, if so, go into a Wait mode.  
When the WinRAR window is found to be no longer running in Windows  I then go on with the execution of the remainder of my application's code.

Thanks for the suggestions.
Thank you jrbbldr