We help IT Professionals succeed at work.

Winrar - Command line to create ZIP Format

jrbbldr asked
Medium Priority
Last Modified: 2013-12-01
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.
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.


Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)


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?



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?

Unlock this solution and get a sample of our free trial.
(No credit card required)


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
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.